No. You don't need to be in the same package to access protected members of an inherited class. The code below works: (1) Q6 is in the _chap5.Q package (2) Q6main_2 is in the _chap5 package
With friendly members, they have to be in the same package. And it doesn't need to be a subclass. Pho
[This message has been edited by Pho Tek (edited April 13, 2001).]
Joined: May 05, 2000
Originally posted by Pho Tek: No. You don't need to be in the same package to access protected members of an inherited class.
That is correct... child classes or classes in the same package can access protected methods. Package access (Java does not call it "friendly" access) limits access to only classes in the same package.