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
You can not access B members with the reference of Parent object A.
Instead change your println statement like below to access,
println
System.out.print(((B)a).sub_var);