Core Access Modifiers in Java | Core Java Free Course

This Core Java Free Course “Access Modifiers in Java” page providing introduction to access modifiers in java, how many access modifiers in java, where we apply these modifiers in java application and why we cannot apply to blocks.


 

Access Modifiers:

  • An Access Modifier is a keyword/modifier.
  • Access Modifiers are differ from general Modifiers.
  • Access Modifiers used to set access permissions on class and class members.
  • Java supports four Access Modifiers which are….
  1. public
  2. private
  3. <package> or <default>
  4. protected.

 

Why we cannot apply Access Modifiers to Blocks?

  • Access Modifiers can be applied only to the members which we can access in the java application(class, variables, methods and constructor).
  • Access Modifiers can be applied to the members which are having identities.
  • Access Modifiers cannot be applied to blocks such as static block, non-static blocks.
  • Blocks execute automatically by the JVM in the application.

 

Following Diagram explains, where we can apply access modifiers in java:

Access Modifiers in Java

Share this