All of the instance field member resolution is done by the JVM but according to the type of the reference variable, that is, the instance field member resolution is not done according to the actual type of the object on the heap which is referred by the reference variable. Thus, the instance field member is also not eligible for runtime polymorphism.
I imagine that there are multiple parts of a polymorphic object in the heap, and the added parts are grown there due to the superclass instances.
Unmesh Chowdhury wrote: Thus, the instance field member is also not eligible for runtime polymorphism.
Correct . that is why it is *better practice to provide setter/getter to an class instead exposing public instance variable directly to other class*. even you can hide the super class instance variable in subclass using private modifier , hence compile time error if you try to access the super class variable using subclass instance --> which violate liskov substitution principle.
hth
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.