Java – Dynamic Method Dispatch

PREV     NEXT

Java Dynamic Method Dispatch:


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 program for Java Dynamic Method Dispatch:

COMPILE & RUN

Output:

B

C

PREV     NEXT




Like it? Please Spread the word!