public class A {
protected int b = 16;
}
public class B extends A{
private int b=20;
public static void main(String[] args)
{
B b = new B();
System.out.println(b.b);
}
}
The output is 20. How can b which refers to an object of type B should not be able to access the private member correct ?
You are getting the value of b in class B. B can access its own private members.