Java MCQs with answers Page - 4

Here, you will find a collection of MCQ questions on Java. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 828.03K Points
Coach

Q. Which version of Java introduced annotation?

  • (A) Java 8
  • (B) Java 7
  • (C) Java 5
  • (D) Java 6

A

Admin • 828.03K Points
Coach

Q. How to get the class object of associated class using Reflection?

  • (A) Class.name(“className”)
  • (B) className.getClassName()
  • (C) Class.forName(“className”)
  • (D) className.getClass()

A

Admin • 828.03K Points
Coach

Q. How method can be invoked on unknown object?

  • (A) obj.getClass().getObject()
  • (B) obj.getClass().getMethod()
  • (C) obj.getClass().getDeclaredField()
  • (D) obj.getClass().getDeclaredMethod()

A

Admin • 828.03K Points
Coach

Q. What is used to get class name in reflection?

  • (A) new getClass()
  • (B) getClass().getDeclaredFields()
  • (C) getClass().getName()
  • (D) getClass().getFields()

A

Admin • 828.03K Points
Coach

Q. How private field can be called using reflection?

  • (A) getFields
  • (B) getDeclaredFields
  • (C) getDeclaredMethods
  • (D) getMethods

A

Admin • 828.03K Points
Coach

Q. How private method can be called using reflection?

  • (A) getFields
  • (B) getMethods
  • (C) getDeclaredFields
  • (D) getDeclaredMethods

A

Admin • 828.03K Points
Coach

Q. What does Class.forName(“myreflection.Foo”).getInstance() return?

  • (A) Foo object
  • (B) Calls the getInstance() method of Foo class
  • (C) class object of Foo
  • (D) An array of Foo objects

A

Admin • 828.03K Points
Coach

Q. What is not the advantage of Reflection?

  • (A) Examine an object’s class at runtime
  • (B) Examine a class’s field at compile time
  • (C) Construct an object for a class at runtime
  • (D) Examine a class’s field and method at runtime

A

Admin • 828.03K Points
Coach

Q. Which of the following is not a marker interface?

  • (A) Remote
  • (B) Serializable
  • (C) Reader
  • (D) Cloneable

A

Admin • 828.03K Points
Coach

Q. What are the components of a marker interface?

  • (A) Fields, no methods
  • (B) No fields, No methods
  • (C) No fields, only methods
  • (D) Fields and methods

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ