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
View Answer
Explanation: Annotation were introduced with Java 5 version.
2. Annotation type definition looks similar to which of the following?
a) Method
b) Class
c) Interface
d) Field
View Answer
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?
a) @Deprecated
b) @Overriden
c) @SafeVarags
d) @FunctionInterface
View Answer
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.
a) True
b) False
View Answer
Explanation: Annotations which are applied to other annotations are called meta annotations.
5. Which one of the following annotations is not used in Hibernate?
a) @Entity
b) @Column
c) @Basic
d) @Query
View Answer
Explanation: @Query is not an annotation used in Hibernate.
6. Which one of the following is not ID generating strategy using @GeneratedValue annotation?
a) Auto
b) Manual
c) Identity
d) Sequence
View Answer
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?
a) @Test
b) @BeforeClass
c) @AfterClass
d) @Ignored
View Answer
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?
a) @VisibleForTesting
b) @NonVisibleForTesting
c) @Visible
d) @NonVisible
View Answer
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?
a) @NoTest
b) @explicit
c) @avoid
d) @ignore
View Answer
Explanation: @ignore annotation is used to avoid execution of Junits.
10. Which is the Parent class of annotation class?
a) Class
b) Object
c) Main
d) Super
View Answer
Explanation: Object is the parent class of annotation class.
Sanfoundry Global Education & Learning Series – Java Programming Language.
To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice BCA MCQs
- Check Java Books
- Apply for Computer Science Internship
- Practice Programming MCQs
- Practice Information Technology MCQs