At run-time, it depends on the type of the object being referred to (not the type of the reference variable) that determines which version of an overridden method will be executed.
A superclass reference variable can refer to a subclass object.
This is also known as upcasting.
Java uses this fact to resolve calls to overridden methods at run time.
|
|
|