Skip to content
Sharp

Java Annotations · interview question

What method would you use to dynamically call a method annotated with a custom annotation at runtime?

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

Correct answer

A. Method.invoke()

Why

Method.invoke() is used to call methods dynamically at runtime. It is often used in conjunction with reflection to execute methods annotated with custom annotations.

Test yourself on Java Annotations

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

Start free test
All Java Annotations questions →