rohit shekhar wrote:
in this code it prints class b, it means we can access subclass method from superclass ref... but in previous case it gives error... 1st prog suggests we cant access subclass methods from superclass but if we will override it then that rule vanish???
I think you are reading too much into it... you are using an "a" reference, which means it is an object that IS-A "a".
In the first example, the a class does not have a disp() method, and in the second case, the a class does.
Henry