Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
The private modifier is an access modifier in object-oriented programming languages that restricts access to members (variables and methods) within a class. Private members can only be accessed from within the same class they are declared in.
Related terms
Public Modifier: The public modifier is another access modifier that allows unrestricted access to members from any other part of the program.
Protected Modifier: The protected modifier grants access to members within the same package or subclasses outside the package but restricts access from unrelated classes.
Default Modifier (Package-private): When no explicit access modifier is specified, members have default access within the same package but are inaccessible from outside the package.