Access specifiers / Access Modifiers / Visibility Modifiers

 

Below matrix provides the details about access specifier and their scope on variable, methods and classes.

Static :

  1. Only one copy will be created in memory (i.e same copy will be available across all the objects created for a particular class)
  2. Can be applied to variables, methods, inner classes and blocks.
  3. Static members will be loaded along with Class loading.
  4. Static members can also be accessed through Class Name along with through the object.
  5. non-static members can not be accessed inside static methods directly.
  6. non-static members can be accessed inside static methods by creating object of the non-static member of the class.
  7. static members can be accessed inside non static members directly.

Access Specifiers Scope
Access Secifiers scope in packages

AccessModifiers