G.3. protected Members
In this section, we introduce access modifier protected. Using protected
access offers an intermediate level of access between public
and private
. A superclass’s protected
members can be accessed by the class, by members of its subclasses and by members of other classes in the same package—protected
members also have package access.
All public
and protected
superclass members retain their original access modifier when they become members of the subclass—public
members of the superclass become public
members of the subclass, and protected
members of the superclass become protected
members of the subclass. A superclass’s private
members are not accessible outside the class itself. Rather, they’re hidden in its subclasses ...
Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.