Access Specifiers in JAVA | What is Access Specifier | Types and how do they work?

AccessSpecifier_Java

What is Access Specifiers

Access specifier defines the accessibility of data members (methods/variables)

Types

  • Public 
  • Private 
  • Protected
  • Default
An easy and quick way to understand how different data members can be accessed with these Access specifiers 

  • Public  - Can be accessed anywhere | Inside and Outside Projects | With and Without Inheritance
  • Private - Can be accessed only Inside a Class
  • Protected - Can be accessed inside and outside the Package. We need to use inheritance to access protected data members outside the class
  • Default - Can be accessed only inside the Package



Comments