Trying to understand Java enhancement. Recently, strange behavior has been observed.
Example:
public class A extends B { public int i = 2; public void printI() { System.out.println("print i = " + this.i); } public static void main(String[] args) { B a = new A();
It seems that an elevated object has two separate “i” properties. One "i" is available directly (ai), and the other using child class methods (a.printI ()).
It seems like an up-level object gets superclass properties and methods from a child class.
How can an object have two separate "i" s ?!
source share