Interestingly both instance variables (message of Parent class and message of Child class) with the same name are kept in ChildObject. The question is how JVM differentiates these 2 variables and saves to the memory. What will be if we synchronize the object?
Basically the child class is simply extending the structure of the parent therefore it will contain a sub-object which can be addressed depending upon the reference type used...
If you are familiar with the C programming language you can observe this effect with the following code snippet:
Rico Felix wrote:Basically the child class is simply extending the structure of the parent therefore it will contain a sub-object which can be addressed depending upon the reference type used...
Thanks a lot Rico. Now it seems to me clear.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.