I am trying to understand why the protected variable in superclass is inaccessible in child class?
package pack1;
public class Parent {
protected int r;
public int s;
}
package pack2;
import pack1.Parent;
public class Child extends Parent {
public static void main(String[] args) {
Parent obj = new Child();
obj.r = 2; //r is not accessible here. It becomes accessible when I make it static.
obj.s = 3; //s is accessible.
}
}