Java: Polymorphism don’t work for variables
Example:
public class Test { public static void main(String[] args) { class A{ private int x; public int getX_A(){return this.x;} } class B extends A{ public int x; public int getX_B(){return this.x;} } B b= new B(); A a = b; a.x = 5; if(a == b){System.out.println("Object equals");} else {System.out.println("Object not equals");} if(a.getX_A() == b.getX_B()){System.out.println("Variables equals");} else {System.out.println("Variables not equals");} } }