Skip to content
Sharp

Reflection API · interview question

In what scenario would you prefer reflection for method invocation over direct method calls?

Multiple choiceMediumchapter-16-curatedpremiumreflection-apidynamic-class-loading
Choose one answer
Answer and explanation

Correct answer

A. When the method name is dynamically determined at runtime.

Why

Reflection is useful for invoking methods when their names are not known until runtime, allowing for more dynamic and flexible code execution.

Test yourself on Reflection API

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

Start free test
All Reflection API questions →