Java ClassesLesson 31Free preview
Java Modifiers
This lesson is part of Java · All levels
Summary
Modifiers are divided into two groups: access modifiers (public, protected, private, default) and non-access modifiers (static, final, abstract, etc.). Access modifiers determine from where a member of a class can be accessed, whereas non-access modifiers set additional behaviors such as belonging to a class or not to be modified. Choosing the right modifier is key to a neat class design.
Key points
- Public can be accessed from anywhere, private only from within the class itself.
- Protected can be accessed in the same package and class derivative
- Without the access modifier means the package-private, only in the same package
- Non-access modifiers such as static and final regulate how members work
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.