posted 19 years ago
Hi Angela
>>B b = new C();
>>b.show();
The method invocation depends on the type of object stored rather than the variable type B.So in the above code B b = new C(), the compiler will first look for the presence of show() method in Class C,if it doesn't finds it, it starts searching in the parent class. So u get B printed in this case.
A a = new C();
a.show();
In this case also samething happens , the search doesn't depend on variable stored but the type of object referred.
cheers
Maha