This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “Annotations”.
1. Which version of Java introduced annotation?
a) Java 5
b) Java 6
c) Java 7
d) Java 8
Explanation: Annotation were introduced with Java 5 version.
2. Annotation type definition looks similar to which of the following?
Explanation: Annotation type definition is similar to an interface definition in which the keyword interface is preceded by the sign @.
3. Which of the following is not pre defined annotation in Java?
Explanation: @Overriden is not a pre defined annotation in Java. @Depricated, @Override, @SuppressWarnings, @SafeVarags and @FunctionInterface are the pre defined annotations.
4. Annotations which are applied to other annotations are called meta annotations.
Explanation: Annotations which are applied to other annotations are called meta annotations.
5. Which one of the following annotations is not used in Hibernate?
Explanation: @Query is not an annotation used in Hibernate.
6. Which one of the following is not ID generating strategy using @GeneratedValue annotation?
Explanation: Auto, Table, Identity and Sequence are the ID generating strategies using @GeneratedValue annotation.
7. Which one of the following is not an annotation used by Junit with Junit4?
Explanation: @Test, @Before, @BeforeClass, @After, @AfterClass and @Ignores are the annotations used by Junit with Junit4.
8. Using which annotation non visible or private method can be tested?
Explanation: Using @VisibleForTesting annotation private or non visible method can be tested.
9. Which of the following annotation is used to avoid execution of Junits?
Explanation: @ignore annotation is used to avoid execution of Junits.
10. Which is the Parent class of annotation class?
Explanation: Object is the parent class of annotation class.
Sanfoundry Global Education & Learning Series – Java Programming Language.