Skip to content
Sharp

Java Annotations · interview question

Which retention policy must be specified to use annotations with reflection?

Multiple choiceEasychapter-16-curatedpremiumjava-annotationscustom-annotations
Choose one answer
Answer and explanation

Correct answer

C. RUNTIME

Why

The RUNTIME retention policy must be specified for annotations that need to be available for reflection at runtime. This allows the annotation data to be accessible during the execution of the program.

Test yourself on Java Annotations

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

Start free test
All Java Annotations questions →