219
95.1k

610+ Java Programming Solved MCQs

These multiple-choice questions (MCQs) are designed to enhance your knowledge and understanding in the following areas: Bachelor of Computer Applications (BCA) , Bachelor of Science in Computer Science (BSc CS) , Master of Computer Applications (MCA) , Programming Languages .

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

Done Studing? Take A Test.

Great job completing your study session! Now it's time to put your knowledge to the test. Challenge yourself, see how much you've learned, and identify areas for improvement. Don’t worry, this is all part of the journey to mastery. Ready for the next step? Take a quiz to solidify what you've just studied.