Skip to content
Sharp

Java Annotations · interview question

What does RetentionPolicy.RUNTIME allow you to do with annotations?

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

Correct answer

A. Access annotations during runtime using reflection

Why

RetentionPolicy.RUNTIME allows annotations to be accessible at runtime via reflection. This is necessary for frameworks that need to inspect or manipulate annotations during the execution of a program.

Test yourself on Java Annotations

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

Start free test
All Java Annotations questions →