Skip to content
Sharp

Java Annotations · interview question

Which of the following retention policies does not allow annotations to be accessed during runtime?

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

Correct answer

B. RetentionPolicy.SOURCE

Why

RetentionPolicy.SOURCE annotations are discarded by the compiler and are not part of the bytecode, making them inaccessible during runtime.

Test yourself on Java Annotations

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

Start free test
All Java Annotations questions →