610+ Java Programming Solved MCQs

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. Swing
302.

Swing is not a part of JFC (Java Foundation Classes) that is used to create GUI application?

A. True
B. False
C. none
D. all
Answer» B. False
303.

These two ways are used to create a Frame By creating the object of Frame class (association) By extending Frame class (inheritance)

A. True
B. False
C. none
D. all
Answer» B. False
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. java.awt.event
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. All of these
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. Panel
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. java.lang.text
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. All mentioned above
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
Answer» C. The Remote Reference Layer
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. rebind ()
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. Provide the Implementation of the remote interface
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. RMI
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. Create the remote interface
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?

A. Server
B. Client
C. Both A & B
D. None of the above
Answer» B. Client
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. UDP
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. All mentioned above
317.

Abbreviate the term DGC?

A. Digital Garbage Collection
B. Distributed Garbage Collection
C. Distributed Garbage Connection
D. None of the above
Answer» B. Distributed Garbage Collection
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. Compile time polymorphism
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. At compile time
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. Abstraction
321.

Which component is responsible to optimize bytecode to machine code?

A. JVM
B. JDK
C. JIT
D. JRE
Answer» C. JIT
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. Java source file header
323.

Which of these packages contains abstract keyword?

A. java.lang
B. java.util
C. java.io
D. java.system
Answer» A. java.lang
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. StringBuffer()
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. length()
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. ello
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. print() and write()
328.

Which keyword is used by the method to refer to the object that invoked it?

A. import
B. catch
C. abstract
D. this
Answer» D. this
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. void
330.

Which of these selection statements test only for equality?

A. if
B. switch
C. if & switch
D. none of the mentioned
Answer» B. switch
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. continue
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. static method
333.

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

A. void
B. int
C. float
D. both int and float
Answer» D. both int and float
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. double
335.

Which of the below is invalid identifier with the main method?

A. public
B. static
C. private
D. final
Answer» C. private
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. keyword
337.

which of the following can be operands of arithmetic operators?

A. Numeric
B. Boolean
C. Characters
D. Both Numeric & Characters
Answer» D. Both Numeric & Characters
338.

How to copy contents of array?

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

Which of these are selection statements in Java?

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

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

A. malloc
B. alloc
C. new
D. give
Answer» C. new
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. java.lang
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. length()
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. sleep()
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. NullPointerException
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. Runnable interface
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. FileInputStream
347.

Which of these classes is used for input and output operation when working with bytes?

A. InputStream
B. Reader
C. Writer
D. All of the mentioned
Answer» A. InputStream
348.

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

A. Math
B. Process
C. System
D. Object
Answer» D. Object
349.

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

A. String
B. StringReader
C. Writer
D. File
Answer» A. String
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. File
351.

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

A. Void
B. Process
C. Runtime
D. System
Answer» D. System
352.

Which of these packages contains all the event handling interfaces?

A. java.lang
B. java.awt
C. java.awt.event
D. java.event
Answer» C. java.awt.event
353.

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

A. try
B. finally
C. thrown
D. catch
Answer» C. thrown
354.

Which of these exceptions handles the divide by zero error?

A. ArithmeticException
B. MathException
C. IllegalAccessException
D. IllegarException
Answer» A. ArithmeticException
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. ArrayIndexOutOfBoundsException
356.

What decides thread priority?

A. Process
B. Process scheduler
C. Thread
D. Thread scheduler
Answer» D. Thread scheduler
357.

Which of the following will ensure the thread will be in running state?

A. yield()
B. notify()
C. wait()
D. Thread.killThread()
Answer» C. wait()
358.

Which of these is used to read a string from the input stream?

A. get()
B. getLine()
C. read()
D. readLine()
Answer» C. read()
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. display()
360.

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

A. display()
B. paint()
C. drawString()
D. tr
Answer» A. display()
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. instanceof
362.

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

A. print()
B. println()
C. write()
D. all of the mentioned
Answer» D. all of the mentioned
363.

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

A. InputStream
B. BufferedInputStream
C. FileInputStream
D. BufferedFileInputStream
Answer» C. FileInputStream
364.

Which of these events is generated by scroll bar?

A. ActionEvent
B. KeyEvent
C. WindowEvent
D. AdjustmentEvent
Answer» D. AdjustmentEvent
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. getActionCommand()
366.

Which of the following is not a primitive data types?

A. Byte.
B. String.
C. Integer.
D. Float.
Answer» B. String.
367.

What is the range of the char type?

A. 0 to 216.
B. 0 to 215.
C. 0 to 216-1.
D. 0 to 215-1.
Answer» D. 0 to 215-1.
368.

Literals in java must be preceded by which of these?

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

Object is an _________ of a class.

A. instance.
B. implement.
C. inheritance.
D. invoke.
Answer» A. instance.
370.

Class is a ______ entity.

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

Object is a _______ entity.

A. normal.
B. physical.
C. logical.
D. normal.
Answer» B. physical.
372.

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

A. definition.
B. declaration.
C. determine.
D. package.
Answer» B. declaration.
373.

______ must be the first non comment statement in the file.

A. package.
B. class.
C. object.
D. declaration.
Answer» A. package.
374.

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

A. variables.
B. objects.
C. methods.
D. operators.
Answer» B. objects.
375.

Every method of a ________ is implicitly final.

A. static class.
B. dynamic class.
C. final class.
D. abstract class.
Answer» C. final class.
376.

A _______ object cannot be modified after it is created.

A. double.
B. int.
C. string.
D. main.
Answer» C. string.
377.

A ____ class may not have any abstract method.

A. abstract.
B. static.
C. final.
D. public.
Answer» C. final.
378.

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

A. 38.
B. 25.
C. 9.
D. 12.
Answer» C. 9.
379.

What will be result of expression 9 | 9?

A. 1.
B. 18.
C. 9.
D. 12.
Answer» C. 9.
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. double.
382.

________ is valid for if statement?

A. An integer expression.
B. A Boolean expression.
C. A character expression.
D. A legal expression.
Answer» B. A Boolean expression.
383.

A package is a collection of ______.

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

________ statement is valid for array declaration.

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

What is the output of relational operators?.

A. integer.
B. boolean.
C. character.
D. double.
Answer» B. boolean.
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.
D. IOException.
Answer» D. IOException.
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. class.
390.

One interface can inherit another by use of the keyword _____.

A. public.
B. extends.
C. method name.
D. class name.
Answer» B. extends.
391.

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

A. abnormal.
B. casual.
C. unfortunate.
D. opposite.
Answer» A. abnormal.
392.

______ is at the top of the exception class hierarchy.

A. try.
B. throwable.
C. exception class.
D. catch.
Answer» B. throwable.
393.

In java thread to thread communication is called _____.

A. passing.
B. sending.
C. messaging.
D. calling.
Answer» C. messaging.
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. public.
395.

Java programs perform I/O through _______.

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

In java a _______ is a sequence of characters.

A. string.
B. arrayChar.
C. groupChar.
D. collection.
Answer» A. string.
397.

The String is defined in _______ namespace.

A. java.Lang.
B. java.String.
C. java.Char.
D. java.Awt.
Answer» A. java.Lang.
398.

__________ is a special member function.

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

Keyword _____ is always a reference to the object.

A. new.
B. this.
C. invoke.
D. class.
Answer» B. this.
400.

________ is the mechanism that binds together the code and the data.

A. polymorphism.
B. encapsulation.
C. inheritance.
D. together.
Answer» B. encapsulation.
Tags
  • Question and answers in Java Programming,
  • Java Programming multiple choice questions and answers,
  • Java Programming Important MCQs,
  • Solved MCQs for Java Programming,
  • Java Programming MCQs with answers PDF download