Java - Interview Questions and Answers on Meta Annotations

Q1.  What are meta Annotations ?

Ans. Annotations that apply to other annotations are called meta-annotations. 

Q2.  Name few meta-annotations ?

Ans. @Retention annotation specifies how the marked annotation is stored:

@Documented annotation indicates that whenever the specified annotation is used those elements should be documented using the Javadoc tool. (By default, annotations are not included in Javadoc.) 

@Target annotation marks another annotation to restrict what kind of Java elements the annotation can be applied to. 

@Inherited annotation indicates that the annotation type can be inherited from the super class. (This is not true by default.) When the user queries the annotation type and the class has no annotation for this type, the class' superclass is queried for the annotation type. This annotation applies only to class declarations.

@Repeatable annotation, introduced in Java SE 8, indicates that the marked annotation can be applied more than once to the same declaration or type use. For more information, see Repeating Annotations.