Skip to content
Sharp

Java Annotations · interview question

Which annotation property must be specified to make an annotation available at runtime?

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

Correct answer

D. @Retention(RetentionPolicy.RUNTIME)

Why

Setting @Retention to RUNTIME ensures that the annotation is retained by the JVM at runtime, allowing reflection to access it.

Test yourself on Java Annotations

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

Start free test
All Java Annotations questions →