class base { int index=5; } class sub extends base { int index=2; public static void main(String[]s) { base b=new sub(); System.out.println(b.index); } } maha, this prints 5.can you explain this please.is variable accessed by the type of reference not with type of object as in the case of methods?