Java MCQ Questions and Answers

11. What is used to find and fix bugs in Java programs.

  1. JDB
  2. JVM
  3. JRE
  4. JDK

Answer : A
Explanation: JDB is the correct answer. The Java Debugger (JDB or jdb) is a command-line java debugger that debugs the java class. It is a part of the Java Platform Debugger Architecture (JPDA) that helps in the inspections and debugging of a local or remote Java Virtual Machine (JVM).

12. What is a Primitive Data Type in Java?

  1. Data Type which is implemented in a machine-dependent way
  2. Data type, which is implemented in an Object-oriented way
  3. Data Type which is implemented in a non-object oriented way
  4. None of the above

Answer : C
Explanation: Data Type which is implemented in a non-object oriented way is known as primitive data type.

13. Is it necessary that each try block must be followed by a catch block?

  1. Yes
  2. No

Answer : B
Explanation: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.

14. Java was publicly released on which date?

  1. 25-05-1995
  2. 29-05-1995
  3. 28-05-1995
  4. 27-05-1995

Answer : D
Explanation: 27-05-1995

15. LinkedHashSet implements:

  1. Set
  2. Cloneable
  3. Serializable
  4. All of the above

Answer : D
Explanation: None

16. Size of float and double in java is

  1. 32 and 64
  2. 64 and 64
  3. 32 and 32
  4. 64 and 32

Answer : A
Explanation: Size of float and double in java is 32 bit and 64 bit respectively.

17. Size of int in java is

  1. 32 bit
  2. 16 bit
  3. 64 bit
  4. None of the above

Answer : A
Explanation: Size of int in java is 32 bit.

18. Which variables are created when an object is created with the use of the keyword ‘new’ and destroyed when the object is destroyed?

  1. Local variables
  2. Class Variables
  3. Instance variables
  4. Static variables

Answer : C
Explanation: Instance variables are created when an object is created with the use of the keyword ‘new’ and destroyed when the object is destroyed.

19. Which is the valid declarations within an interface definition?

  1. public double methoda();
  2. public final double methoda();
  3. static void methoda(double d1);
  4. protected void methoda(double d1);

Answer : A
Explanation: A public access modifier is acceptable. The method prototypes in an interface are all abstract by virtue of their declaration, and should not be declared abstract. Option A is correct.

20. What allows the programmer to destroy an object x?

  1. x.finalize()
  2. x.delete()
  3. Runtime.getRuntime().gc()
  4. Only the garbage collection system can destroy an object

Answer : D
Explanation: When an object is no longer referenced, it may be reclaimed by the garbage collector. If an object declares a finalizer, the finalizer is executed before the object is reclaimed to give the object a last chance to clean up resources that would not otherwise be released. When a class is no longer needed, it may be unloaded.

This Post Has 2 Comments

Leave a Reply