(you should probably use examples that compile by the way
)
Okay, so specifically you are using the concept called Polymorphism. "A superclass reference variable can reference objects of a subclass"
so because of dynamic binding, your animal object will check to see what kind of object is actually has during run time,
then when it calls its method "s.o.p" the override method will take over because of polymorphism. This you saw working when your method printed 20.
I found this googling
"overiding class variables java"
"In short, no, there is no way to override a class variable.
You do not override class variables in Java you hide them. Overriding is for instance methods. Hiding is different from overriding.
In the example you've given, by declaring the class variable with the name 'me' in class Son you hide the class variable it would have inherited from its superclass Dad with the same name 'me'. Hiding a variable in this way does not affect the value of the class variable 'me' in the superclass Dad."
so since the Animal Object is just POINTING to the address of a CAT Object, I think it uses the ANIMAL "i" instance variable.
I could be a little off, anyone want to double check my wording?