class A { int super_var = 1; } class B extends A { int sub_var = 2; } public class Demo{ public static void main(String []args){ A a = new
The sub_var is in class B, so you can only access through a reference of class B. To the compiler A a = new B(); means a is an instance of class A.
sub_var
class B
A a = new B();
a
class A