Java-Programming (Set 4)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Java Programming

4 of 7 sets

301. The following specifies the advantages of It is lightweight. It supports


pluggable look and feel. It follows MVC (Model View Controller) architecture.
A. Swing
B. AWT
C. Both A & B
D. None of the above
Answer:A

302. Swing is not a part of JFC (Java Foundation Classes) that is used to create
GUI application?
o m
A. True
. c
B. False
te
C. none
a
D. all

q M
Answer:B
c
Mto create a Frame By creating the object of Frame
303. These two ways are used
class (association) By extending Frame class (inheritance)
A. True
B. False
C. none
D. all
Answer:B

304. Which package provides many event classes and Listener interfaces for event
handling?
A. java.awt
B. java.awt.Graphics
C. java.awt.event
D. None of the above
Answer:C
305. The ActionListener interface is used for handling action events,For
example,it's used by a
A. JButton
B. JCheckbox
C. JMenuItem
D. All of these
Answer:D

306. Which is the container that doesn't contain title bar and MenuBars. It can
have other components like button, textfield etc?
A. Window
B. Frame
C. Panel
D. Container
Answer:C

307. Which of these package is used for all the text related modifications?
A. java.text
B. java.awt
C. java.lang.text
D. java.text.mofify
Answer:C

308. RMI has which of these protocols implementations?


A. Java Remote Method Protocol (JRMP)
B. Internet Inter-ORB Protocol (IIOP)
C. Jinni Extensible Remote Invocation (JERI)
D. All mentioned above
Answer:D

309. In RMI which layer defines and supports the invocation semantics of the RMI
connection, this layer maintains the session during the method call?
A. The Stub & Skeleton Layer
B. The Application Layer
C. The Remote Reference Layer
D. The Transport Layer

View all MCQ's at McqMate.com


Answer:C

310. Which method of the Naming class (found in java.rmi) is used to update the
RMI registry on the server machine?
A. rebind ()
B. lookup()
C. Both A & B
D. None of the above
Answer:A

311. In RMI program the following two steps are used to, Either extend the
UnicastRemoteObject class, the exportObject() method of the
UnicastRemoteObject class,
A. Provide the Implementation of the remote interface
B. Create the remote interface
C. Create and start the remote application
D. Compile the implementation class and create the stub and skeleton objects using the rmic tool
Answer:A

312. Which is built on the top of socket programming?


A. EJB
B. RMI
C. Both A & B
D. None of the above
Answer:B

313. In RMI program the following example shows the, import java.rmi.*; public
interface Adder extends Remote{ public int add(int x,int y)throws
RemoteException; }
A. Create and start the remote application
B. Create and start the client application
C. Create the remote interface
D. Provide the implementation of the remote interface
Answer:C

314. In RMI applications which program obtains a remote reference to one or


more remote objects on a server and then invokes methods on them?

View all MCQ's at McqMate.com


A. Server
B. Client
C. Both A & B
D. None of the above
Answer:B

315. Which is a one-way communication only between the client and the server and
it is not a reliable and there is no confirmation regarding reaching the message to
the destination?
A. TCP/IP
B. UDP
C. Both A & B
D. None of the above
Answer:B

316. In a RMI Client Program, what are the exceptions which might have to
handled?
A. RemoteException
B. NotBoundException
C. MalFormedURLException
D. All mentioned above
Answer:D

317. Abbreviate the term DGC?


A. Digital Garbage Collection
B. Distributed Garbage Collection
C. Distributed Garbage Connection
D. None of the above
Answer:B

318. Which of the following is a type of polymorphism in Java?


A. Compile time polymorphism
B. Execution time polymorphism
C. Multiple polymorphism
D. Multilevel polymorphism
Answer:A

View all MCQ's at McqMate.com


319. When does method overloading is determined?
A. At run time
B. At compile time
C. At coding time
D. At execution time
Answer:B

320. Which concept of Java is a way of converting real world objects in terms of
class?
A. Polymorphism
B. Encapsulation
C. Abstraction
D. Inheritance
Answer:C

321. Which component is responsible to optimize bytecode to machine code?


A. JVM
B. JDK
C. JIT
D. JRE
Answer:C

322. How can we identify whether a compilation unit is class or interface from a
.class file?
A. Java source file header
B. Extension of compilation unit
C. We cannot differentiate between class and interface
D. The class or interface name should be postfixed with unit type
Answer:A

323. Which of these packages contains abstract keyword?


A. java.lang
B. java.util
C. java.io
D. java.system

View all MCQ's at McqMate.com


Answer:A

324. Which of these class is used to create an object whose character sequence is
mutable?
A. String()
B. StringBuffer()
C. String() & StringBuffer()
D. None of the mentioned
Answer:B

325. Which of these method of class StringBuffer is used to find the length of
current character sequence?
A. length()
B. Length()
C. capacity()
D. Capacity()
Answer:A

326. What is the string contained in s after following lines of code? StringBuffer s
new StringBuffer("Hello"); s.deleteCharAt(0);
A. Hell
B. ello
C. Hel
D. llo
Answer:B

327. Which of these method(s) is/are used for writing bytes to an outputstream?
A. put()
B. print() and write()
C. printf()
D. write() and read()
Answer:B

328. Which keyword is used by the method to refer to the object that invoked it?
A. import
B. catch

View all MCQ's at McqMate.com


C. abstract
D. this
Answer:D

329. What is the return type of a method that does not return any value?
A. int
B. float
C. void
D. double
Answer:C

330. Which of these selection statements test only for equality?


A. if
B. switch
C. if & switch
D. none of the mentioned
Answer:B

331. Which of these jump statements can skip processing the remainder of the code
in its body for a particular iteration?
A. break
B. return
C. exit
D. continue
Answer:D

332. Which of these is the method which is executed first before execution of any
other thing takes place in a program?
A. main method
B. finalize method
C. static method
D. private method
Answer:C

333. Which of these data type can be used for a method having a return statement
in it?

View all MCQ's at McqMate.com


A. void
B. int
C. float
D. both int and float
Answer:D

334. If an expression contains double, int, float, long, then the whole expression will
be promoted into which of these data types?
A. long
B. int
C. double
D. float
Answer:C

335. Which of the below is invalid identifier with the main method?
A. public
B. static
C. private
D. final
Answer:C

336. Which of these can not be used for a variable name in Java?
A. identifier
B. keyword
C. identifier & keyword
D. none of the mentioned
Answer:B

337. which of the following can be operands of arithmetic operators?


A. Numeric
B. Boolean
C. Characters
D. Both Numeric & Characters
Answer:D

338. How to copy contents of array?

View all MCQ's at McqMate.com


A. System.arrayCopy()
B. Array.copy()
C. Arrays.copy()
D. Collection.copy()
Answer:A

339. Which of these are selection statements in Java?


A. if()
B. for()
C. continue
D. break
Answer:A

340. Which of these operators is used to allocate memory for an object?


A. malloc
B. alloc
C. new
D. give
Answer:C

341. Which of these packages contains the exception Stack Overflow in Java?
A. java.lang
B. java.util
C. java.io
D. java.system
Answer:A

342. Which of this method of class String is used to obtain a length of String
object?
A. get()
B. Sizeof()
C. lengthof()
D. length()
Answer:D

View all MCQ's at McqMate.com


343. Which of these methods of a Thread class is used to suspend a thread for a
period of time?
A. sleep()
B. terminate()
C. suspend()
D. stop()
Answer:A

344. Which of these exceptions will be thrown if we use null reference for an
arithmetic operation?
A. ArithmeticException
B. NullPointerException
C. IllegalAccessException
D. IllegalOperationException
Answer:B

345. Which of the interface contains all the methods used for handling thread
related operations in Java?
A. Runnable interface
B. Math interface
C. System interface
D. ThreadHandling interface
Answer:A

346. Which of these class is used to read and write bytes in a file?
A. FileReader
B. FileWriter
C. FileInputStream
D. InputStreamReader
Answer:C

347. Which of these classes is used for input and output operation when working
with bytes?
A. InputStream
B. Reader
C. Writer

View all MCQ's at McqMate.com


D. All of the mentioned
Answer:A

348. Which of these class is a superclass of all other classes?


A. Math
B. Process
C. System
D. Object
Answer:D

349. Which of these class is not a member class of java.io package?


A. String
B. StringReader
C. Writer
D. File
Answer:A

350. Which of these class is not related to input and output stream in terms of
functioning?
A. File
B. Writer
C. InputStream
D. Reader
Answer:A

351. Standard output variable ‘out’ is defined in which class?


A. Void
B. Process
C. Runtime
D. System
Answer:D

352. Which of these packages contains all the event handling interfaces?
A. java.lang
B. java.awt
C. java.awt.event

View all MCQ's at McqMate.com


D. java.event
Answer:C

353. Which of these keywords is not a part of exception handling?


A. try
B. finally
C. thrown
D. catch
Answer:C

354. Which of these exceptions handles the divide by zero error?


A. ArithmeticException
B. MathException
C. IllegalAccessException
D. IllegarException
Answer:A

355. Which of these exceptions will occur if we try to access the index of an array
beyond its length?
A. ArithmeticException
B. ArrayException
C. ArrayIndexException
D. ArrayIndexOutOfBoundsException
Answer:D

356. What decides thread priority?


A. Process
B. Process scheduler
C. Thread
D. Thread scheduler
Answer:D

357. Which of the following will ensure the thread will be in running state?
A. yield()
B. notify()
C. wait()

View all MCQ's at McqMate.com


D. Thread.killThread()
Answer:C

358. Which of these is used to read a string from the input stream?
A. get()
B. getLine()
C. read()
D. readLine()
Answer:C

359. Which of these methods can be used to output a string in an applet?


A. display()
B. print()
C. drawString()
D. tr
Answer:A

360. Which of these methods is a part of Abstract Window Toolkit (AWT) ?


A. display()
B. paint()
C. drawString()
D. tr
Answer:A

361. Which of these operators can be used to get run time information about an
object?
A. getInfo
B. Info
C. instanceof
D. getinfoof
Answer:C

362. Which of these methods can be used to writing console output?


A. print()
B. println()
C. write()

View all MCQ's at McqMate.com


D. all of the mentioned
Answer:D

363. Which of these class is used to read from a file?


A. InputStream
B. BufferedInputStream
C. FileInputStream
D. BufferedFileInputStream
Answer:C

364. Which of these events is generated by scroll bar?


A. ActionEvent
B. KeyEvent
C. WindowEvent
D. AdjustmentEvent
Answer:D

365. Which of these methods can be used to obtain the command name for
invoking ActionEvent object?
A. getCommand()
B. getActionCommand()
C. getActionEvent()
D. getActionEventCommand()
Answer:B

366. Which of the following is not a primitive data types?


A. Byte.
B. String.
C. Integer.
D. Float.
Answer:B

367. What is the range of the char type?


A. 0 to 216.
B. 0 to 215.
C. 0 to 216-1.

View all MCQ's at McqMate.com


D. 0 to 215-1.
Answer:D

368. Literals in java must be preceded by which of these?


A. L.
B. l.
C. D.
D. both a & b.
Answer:D

369. Object is an _________ of a class.


A. instance.
B. implement.
C. inheritance.
D. invoke.
Answer:A

370. Class is a ______ entity.


A. logical.
B. physical.
C. up normal.
D. collection of.
Answer:A

371. Object is a _______ entity.


A. normal.
B. physical.
C. logical.
D. normal.
Answer:B

372. ______ can appear anywhere in the body of a java method.


A. definition.
B. declaration.
C. determine.

View all MCQ's at McqMate.com


D. package.
Answer:B

373. ______ must be the first non comment statement in the file.
A. package.
B. class.
C. object.
D. declaration.
Answer:A

374. _______ is passed to a method by use of call-by-reference.


A. variables.
B. objects.
C. methods.
D. operators.
Answer:B

375. Every method of a ________ is implicitly final.


A. static class.
B. dynamic class.
C. final class.
D. abstract class.
Answer:C

376. A _______ object cannot be modified after it is created.


A. double.
B. int.
C. string.
D. main.
Answer:C

377. A ____ class may not have any abstract method.


A. abstract.
B. static.
C. final.

View all MCQ's at McqMate.com


D. public.
Answer:C

378. What will be the result of the expression 13 & 25?


A. 38.
B. 25.
C. 9.
D. 12.
Answer:C

379. What will be result of expression 9 | 9?


A. 1.
B. 18.
C. 9.
D. 12.
Answer:C

380. _________ Operators are overloaded for string objects?


A. -, +.
B. +, =.
C. <<, >>.
D. ++, --.
Answer:B

381. If an expression contains double, int, float, long, then whole expression will
promoted into which of these data types?.
A. .long
B. int.
C. double.
D. float.
Answer:C

382. ________ is valid for if statement?


A. An integer expression.
B. A Boolean expression.
C. A character expression.

View all MCQ's at McqMate.com


D. A legal expression.
Answer:B

383. A package is a collection of ______.


A. keywords.
B. classes and interfaces.
C. editing tools.
D. views.
Answer:B

384. ________ statement is valid for array declaration.


A. int number ();.
B. float number ();.
C. float number [];.
D. count Int [];.
Answer:C

385. What is the output of relational operators?.


A. integer.
B. boolean.
C. character.
D. double.
Answer:B

386. Which of these operators can skip evaluating right hand operand?.
A. !.
B. |.
C. &.
D. &&.
Answer:D

387. Which exception is thrown by the read () method of Input Stream class?
A. Exception.
B. ClassNotFoundException.
C. read Exception.

View all MCQ's at McqMate.com


D. IOException.
Answer:D

388. Which of the following denotes a javadoc comment?


A. //#.
B. /*.
C. /**.
D. //**.
Answer:C

389. Using the keyword interface you can fully abstract a _________.
A. method.
B. keyword
C. class.
D. variables.
Answer:C

390. One interface can inherit another by use of the keyword _____.
A. public.
B. extends.
C. method name.
D. class name.
Answer:B

391. An exception is an __________ condition that arises in a code.


A. abnormal.
B. casual.
C. unfortunate.
D. opposite.
Answer:A

392. ______ is at the top of the exception class hierarchy.


A. try.
B. throwable.
C. exception class.

View all MCQ's at McqMate.com


D. catch.
Answer:B

393. In java thread to thread communication is called _____.


A. passing.
B. sending.
C. messaging.
D. calling.
Answer:C

394. Which of these access specifiers can be used for an interface?.


A. public.
B. protected.
C. private.
D. All of the mentioned.
Answer:A

395. Java programs perform I/O through _______.


A. i/o methods.
B. i/o package.
C. streams.
D. compiler.
Answer:C

396. In java a _______ is a sequence of characters.


A. string.
B. arrayChar.
C. groupChar.
D. collection.
Answer:A

397. The String is defined in _______ namespace.


A. java.Lang.
B. java.String.
C. java.Char.

View all MCQ's at McqMate.com


D. java.Awt.
Answer:A

398. __________ is a special member function.


A. method.
B. class.
C. use defined function.
D. constructor.
Answer:D

399. Keyword _____ is always a reference to the object.


A. new.
B. this.
C. invoke.
D. class.
Answer:B

400. ________ is the mechanism that binds together the code and the data.
A. polymorphism.
B. encapsulation.
C. inheritance.
D. together.
Answer:B

View all MCQ's at McqMate.com

You might also like