Access modifier

  • Eclipse: Oxygen
  • Java: 1.8

Access modifier- The concept is explained with the help of a table which includes all levels of access.(in the class) which also includes packages, subclass, and non-subclass.

The public variable is visible everywhere in contrast to the private variable which is local variable to a class and protected variable which is also not visible in the different classes until It has the same package.

App.Java

Output

Value of x is 10
10

B.Java

Output

Value of x is 10
10

A.Java

Output

Value of x is 10
10

 

Contributed by: Poonam Tomar


VIEW COURSES

Buy me a coffee!

 

PayTM QR (INDIA)

  • Get video tutorials
  • Project files set
  • Get┬áCertified

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu