I would expect this code:
....to produce the following output:
But instead it produces:
I was wrong in the output for the 1st & 3rd lines from the end.
Why???
I am following the following tutorial:
http://www.beginner-java-tutorial.com/java-method-overriding.html Where they say:
The following distinction between invoking instance methods on an object and accessing fields of an object must be noted. When an instance method is invoked on an object using a reference, it is the class of the current object denoted by the reference, not the type of the reference, that determines which method implementation will be executed. When a field of an object is accessed using a reference, it is the type of the reference, not the class of the current object denoted by the reference, that determines which field will actually be accessed. This is demonstrated in the above program.