Skip to content
Sharp

Object-oriented programming · interview question

Which situation could lead to a problem when a subclass overrides a method?

Multiple choiceHardchapter-5-curatedpremiumoopmethod-overriding
Choose one answer
Answer and explanation

Correct answer

D. The subclass method uses a wider checked exception.

Why

A subclass cannot throw a wider checked exception than the method it overrides. This would violate the exception handling contract established by the superclass method.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →