Skip to content
Sharp

Java Annotations · interview question

Which retention policy if none is specified for a custom annotation is the default in Java?

Multiple choiceEasychapter-16-curatedpremiumjava-annotationsretention-policies
Choose one answer
Answer and explanation

Correct answer

B. RetentionPolicy.CLASS

Why

If no retention policy is specified for a custom annotation, the default is RetentionPolicy.CLASS. This means the annotation is recorded in the class file 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 →