Java Modifiers

Modifiers divided into two groups:

  1. Access Modifiers – controls the access level
    • public : The class is accessible by any other class
    • private : The code is only accessible within the declared class
    • protected : The code is accessible in the same package and subclasses.
    • default : The class is only accessible by classes in the same package. This is used when you don’t specify a modifier.
  2. Non-Access Modifiers – do not control access level, but provides other functionality
    • final — For classes
    • static : Attributes( class variable/field member ) and methods belongs to the class, rather than an object.
    • abstract — (For classes ) Can only be used in an abstract class, and can only be used on methods. The method does not have a body, for example abstract void run();. The body is provided by the subclass (inherited from).
    • transient :
    • synchronized :
    • volatile :

public