Skip to content
Sharp

Java Annotations · interview question

Which Java annotation is used to specify that an annotation type should be automatically inherited?

Multiple choiceEasychapter-16-curatedpremiumjava-annotationsannotation-processors
Choose one answer
Answer and explanation

Correct answer

D. @Inherited

Why

@Inherited is a meta-annotation that indicates the annotated type will be inherited by subclasses. This is useful for annotations that need to apply to a class hierarchy.

Test yourself on Java Annotations

A free test with instant, explained results. No account needed.

Start free test
All Java Annotations questions →