πŸ“Š JAVA
Q. Annotation type definition looks similar to which of the following?
  • (A) Interface
  • (B) Field
  • (C) Class
  • (D) Method
πŸ’¬ Discuss
βœ… Correct Answer: (A) Interface
πŸ“Š JAVA
Q. Which version of Java introduced annotation?
  • (A) Java 8
  • (B) Java 7
  • (C) Java 5
  • (D) Java 6
πŸ’¬ Discuss
βœ… Correct Answer: (C) Java 5
πŸ“Š JAVA
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()
πŸ’¬ Discuss
βœ… Correct Answer: (C) Class.forName(“className”)
πŸ“Š JAVA
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()
πŸ’¬ Discuss
βœ… Correct Answer: (B) obj.getClass().getMethod()
πŸ“Š JAVA
Q. What is used to get class name in reflection?
  • (A) new getClass()
  • (B) getClass().getDeclaredFields()
  • (C) getClass().getName()
  • (D) getClass().getFields()
πŸ’¬ Discuss
βœ… Correct Answer: (C) getClass().getName()
πŸ“Š JAVA
Q. How private field can be called using reflection?
  • (A) getFields
  • (B) getDeclaredFields
  • (C) getDeclaredMethods
  • (D) getMethods
πŸ’¬ Discuss
βœ… Correct Answer: (D) getMethods
πŸ“Š JAVA
Q. How private method can be called using reflection?
  • (A) getFields
  • (B) getMethods
  • (C) getDeclaredFields
  • (D) getDeclaredMethods
πŸ’¬ Discuss
βœ… Correct Answer: (D) getDeclaredMethods
πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) Foo object
πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Examine a class’s field at compile time
πŸ“Š JAVA
Q. Which of the following is not a marker interface?
  • (A) Remote
  • (B) Serializable
  • (C) Reader
  • (D) Cloneable
πŸ’¬ Discuss
βœ… Correct Answer: (C) Reader