Skip to content
Sharp

Object-oriented programming · interview question

What happens when you call a method on an object stored in a variable of its superclass type?

Multiple choiceMediumchapter-5-curatedpremiumooppolymorphism
Choose one answer
Answer and explanation

Correct answer

C. The method from the object's actual class is invoked

Why

In Java, when you call a method on an object stored in a variable of its superclass type, the method of the object's actual class is invoked. This is known as dynamic method dispatch or runtime polymorphism.

Test yourself on Object-oriented programming

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

Start free test
All Object-oriented programming questions →