protected Members
- public members of a superclass are accessible by all methods in the program.
- private members of a superclass are accessible only by methods of the superclass.
- This all or nothing choice is softened by a 3rd option: protected.
- protected members of a superclass can be accessed only by:
- methods of the superclass;
- methods of the subclasses;
- methods in other classes in the same package (you don't need to know what a package is for this course).
- Subclass methods normally refer to public, protected, and friendly members of the superclass simply by using
the member names.
- When a sublcass method overrides a superclass method, the superclass method can be accessed from the subclass
by preceding the superclass method name with super. .
public void init() {
super.init();
...
}