Class Members
Access to class members of all types is controlled by access modifier keywords and the no-keyword default as follows:
public— A public member is accessible from any class in the program.
protected— A protected member can be accessed only by classes in the same package and classes derived from the current class—no matter which package they are in.
private— A private member can be accessed only from within the class.
default— If none of the other access modifier keywords appear, the default applies (access only by classes in the same package). You may see the word “friendly” used in connection with the default access, but “friendly” is not a Java keyword.
Other keywords that can be applied to class members are static, final, abstract ...
Get Java 2™ Programmer Exam Cram™ 2 (Exam CX-310-035) 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.