Java only allows the subclass to access protected members, that are in a different package, if it is "responsible for the implementation".... ie. if it can determine the type IS-A the subclass. If you want to access the protected member, while using a superclass reference, you will need to cast it first.
It's simply a rule of the language. Protected members may only be accessed when the type of the expression on which you perform the access is strictly a subclass of the class that declares the protected member.
That is because:
protected variables can be accessed either in the same package or via extended class in any package
Now, when you do Acc a = new Test(); a reference variable is of type Acc, not of type Test. And since Acc class is declared in package p1 and you instantiated object in package p2, you can't access it unless you'd cast it to Test type in which way you'd be accessing it via extended class. i.e.