In the following code why is the O/p "hello in base"?
is it not true that we cant access private methods of a superclass with a sub class reference.
Manivannan
We cant access private methods of a superclass with a sub class reference.
See "ref" is the Superclass Reference But it contains Subclass Object. So by using Superclass Refernce only we can access the Private Method.
but my doubt was that i have a private method hello() in class Base and a public method hello() in sub class Class Sub. ref is a reference of superclass BUT it contains an object of subclass so why the method hello() of sub class is not called from method() in the class Base.
Srini
Srini
Srini
Srini
Don't get me started about those stupid light bulbs. |