Skip to content
Sharp

Reflection API · interview question

What happens if Method.invoke() is used on a method that throws a checked exception?

Multiple choiceMediumchapter-16-curatedpremiumreflection-apimethod-invoke
Choose one answer
Answer and explanation

Correct answer

C. InvocationTargetException is thrown.

Why

When a method invoked by Method.invoke() throws a checked exception, it is wrapped in an InvocationTargetException. You need to unwrap it to access the original exception.

Test yourself on Reflection API

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

Start free test
All Reflection API questions →