Understanding Java Access Modifiers

   Outer Class   Inner Class   Methods   Variables   Blocks  Outer Interface Inner Interface  Outer Enum   Inner Enum   Constructor 
Public Y Y Y Y Y Y Y Y Y
Private  - Y Y Y Y Y Y
Protected  - Y Y Y Y Y Y
Default Y Y Y Y Y Y Y Y Y
Final Y Y Y Y
Abstract Y Y Y Y Y
Static  - Y Y Y Y Y Y
Synchronized Y Y
Native Y
Strictfp Y Y Y  - Y Y
Transient Y -
Volatile Y

 

  • The modifiers which are applicable for inner classes but not for outer classes are Private,Protected and Static
  • The modifiers which are applicable for classes but not for interface are Final
  • The modifiers which are applicable for classes but not for enums are Final and Abstract
  • The modifiers which are applicable only for methods are Native
  • Interface defined inside a class  is static weather we are declaring or not
  • Interface defined inside a interface is static and public weather we are declaring or not
  • Class defined inside a interface is static and public weather we are declaring or not