Title: Key Concept - Access Modifiers
Course: CPS 189: Java Certification - Review, Practice & Prepare (Development) > Section: (OLDstyle) Learning Modules

Access Modifiers

- Access modifiers control how a class, field, or method may be accessed outside the class.

Access Modifiers include:

- Public: The member is accessible from all other classes
- Private: The member is accessible only within the class

- A class must be declared public, abstract, or final.
- Generally, fields are declared private while methods are declared public.
- Declaring a field or method private carries out encapsulation.

Class member visibility table:

Modifier | Is the member visible in the class? | Is the member visible in the package? | Is the member visible in subclasses of the class declared outside the package? | Is the member visible everywhere?
Public | YES | YES | YES | YES
Protected | YES | YES | YES | NO
No Modifier | YES | YES | NO | NO
Private | YES | NO | NO | NO

For more information about Access Modifiers:

- Click this link to view Oracle's documentation: Controlling Access to Members of a Class.
- Level 1 Study Materials: Unit 5