Skip to content
Sharp

Java Annotations · interview question

Given the following custom annotation, what is the default retention policy if none is specified?

Multiple choiceHardchapter-16-curatedpremiumjava-annotationscustom-annotations
java
@interface MyAnnotation {}
Choose one answer
Answer and explanation

Correct answer

A. CLASS

Why

If no retention policy is specified, the default is CLASS, meaning the annotation is present in the bytecode but not available at runtime.

Test yourself on Java Annotations

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

Start free test
All Java Annotations questions →