Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
270 Members
Join this group to post and comment.
Archana Priyadarshini
Archana Priyadarshini
Computer Science
25 Jan 2019

Java Modifiers

There are three access modifiers keywords in Java- public ,private,protected

There are four access levels- public , protected, default and private.

They define how the corresponding element is visible to other components.

If something is declared public, e.g., classes or methods can be freely created or called by other Java objects. If something is declared private, e.g., a method, it can only be accessed within the class in which it is declared.

The access levels protected and default are similar. A protected class can be accessed from the package and sub-classes outside the package, while a default class can get accessed only via the same package.

Non access modifiers include

  • The static modifier for creating class methods and variables.

  • The final modifier for finalizing the implementations of classes, methods, and variables.

  • The abstract modifier for creating abstract classes and methods.

  • The synchronized and volatile modifiers which are used for threads.