Java – Dynamic Method Dispatch

PREV     NEXT

A superclass reference can refer to a subclass object. Whenever an overridden method is called through that superclass reference, then the call to that overridden method is resolved at run time based on the object being referred by the superclass reference.

Example:

COMPILE & RUN

Output:

B


C

PREV     NEXT

Share this website !!!
Facebook Twitter Linkedin