When trying to access a protected member of an instance, that is declared in the super class, and through a reference variable, and the subclass types are in different packages (wow, did I qualify it enough?), then this rule from the JLS applies....
6.6.2 Details on protected Access
A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object.
The key phrase is responsible for the implementation. This means that B can only access via B type references. And C can only access via C type references.... and since a C instance IS-A B instance, this means that the B class can access via both B and C type references, but the C class can only access via C type references. And neither B or C class can access using a A type reference. Is that confusing enough? ...
Sahil Kapoor wrote:
In Nutshell , you cannot say to your father, Hey access your pf , but Father can say to its child "Hey Son/daughter access your pf ".
I don't think that's a good way to think about it. I think it is better to think that only objects that IS-A YOU can be accessed by YOU.
In the case of B, both B and C references are guaranteed to be IS-A B instances. And hence, both objects are guaranteed to have the same permissions of B, which means that both objects can be accessed by B.
In the case of C, while a C reference IS-A B, the reverse is not true. In fact, it could be an entirely new class type, say D, that inherits from B, that is in a completely different package. So, the B references is not guaranteed to hold an objects that IS-A C, and hence, can't be accessed by C.