Hmmm i am not sure if you are worrying the polymophism
or the reference side when you made the statement
S0 s0 = new S2();
anyway someone (Jane) makes everything clearer to me.
1. the method display() of S2 overriding the display()
method of S1, when ever s2.display() will invoke the
instance method of s2.
2. if you dont write the display() method at S2 class
(ie not overriding it) , instance object of s2 will
automaticly use the parent's display() method
( the power of
polymorphism )
3. however when the statement is: S0 s0 = new S2();
s0 is the object reference of type S0 but it is
holding an instance object of S2.
s0.display() will call the display method of
S2 type object.
Say reference s0 is an address of 0x0001 so "what is at"
that address is an instance of S2 object
I hope that's help and correct me if I am wrong please
Ferry
"the only way for you to understand is to make others people
can understand your explanation"