Annotations
1.Which symbol is used to declare an annotation in Java?
-
A. @
-
B. #
-
C. $
-
D. &
@
@
2.Which of the following is NOT a standard meta-annotation in Java?
-
A. @Target
-
B. @Retention
-
C. @Deprecated
-
D. @Documented
@Deprecated
@Deprecated
3.What does the @Retention meta-annotation specify?
-
A. Where an annotation can be applied (e.g., class, method).
-
B. How long the annotation will be retained (e.g., source, class, runtime).
-
C. Whether the annotation should be included in Javadoc.
-
D. Whether the annotation can be inherited by subclasses.
How long the annotation will be retained (e.g., source, class, runtime).
How long the annotation will be retained (e.g., source, class, runtime).
4.Which retention policy makes an annotation available at runtime via reflection?
-
A. SOURCE
-
B. CLASS
-
C. RUNTIME
-
D. COMPILE
RUNTIME
RUNTIME
5.What is the primary purpose of annotations in Java?
-
A. To provide additional data or metadata about program elements.
-
B. To improve the performance of the application.
-
C. To replace traditional inheritance.
-
D. To define new data types.
To provide additional data or metadata about program elements.
To provide additional data or metadata about program elements.