1) When both super and sub classes have same signature methods, a subclass reference holding a subclass object invokes subclass version of the method and a super class reference holding a super class object invokes super class version of the method. This is straightforward. But when a super class reference holding a sub class object, invokes the method, the sub class version of the method is run by JVM. This is called Dynamic method dispatch or Polymorphic method invocation in simple words
Polymorphism.
2) This concept is NOT applicable for variables. Meaning if both super and sub classes have variable with same name, super class reference prints super class version of the variable (irrespective of whether it holds super class object or sub class object) and sub class reference prints sub class version of the variable.
Now if you apply these two concepts, the program and output you posted will make sense.
P.S. You may have to read two or three times the two points above to avoid confusion.