Hi mathur Thanks for your reply . see the below code .
i was bit even more confused .... but upto some extend i will agree with you . see the output for the this code .i added one more method in class Az.
Joined: Oct 30, 2001
The revised version doesn't do what you say it does: -
The original version does do what you say: -
In the original, there is no overriding of any of the m1(something) methods. The three classes provide three different overloads of it.
The variable c1 is declared to contain an Az object. When choosing between overloads, it is the declared type that determines what happens. There is only one method in Az that matches c1.m1(c2); it's the one that prints "A".
In the modified version, the class Az has a method m1(Cz) that is overridden in class Cz. When choosing between overrides, it is the run-time type that matters. So, because c1's run-time type is Cz, the method in Cz is called, printing "C". [ August 20, 2007: Message edited by: Peter Chase ]
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P