Access Specifiers In JAVA

Hey viewers, welcome to my blog. Today I Will be explaining about Access Specifier in java.

Now you might be having a number of questions in your mind. For example –

  • What are Access, Specifiers?
  • Where are they used? and 
  • How are they used? etc. 

Don’t worry I will be answering all these questions.

Let’s get started,

These specifiers are used to restrict the scope of a class, constructor, variable, method or data member. These are also known as Access Modifiers.

There are different kinds of access specifiers which are as follows:-

  1. Default – No keyword required
  2. Private
  3. Protected
  4. Public


  1. Default:

Now let’s understand these access specifiers one by one default: If no access modifier is specified for a class, method or data member, then they act as a default access modifier. They are accessible only within the same package.

Example:- Default Access modifiers2. Private:

Moving forward,this is specified using the private keyword.

Data members or methods declared as private are accessible only within the class in which they are declared. Other class of the same package will not be able to access these members. Class and interfaces cannot be declared private.



Data members or methods declared as protected are accessible within same package or subclasses in the different package.

Example:- protected access modifiers

  1. Public:

    This is specified using the public keyword.

It has the widest scope among all other access modifiers. Classes, data members or methods declared as the public are accessible from everywhere in the program.

 Example:- public access modifiersI hope this article help you understanding the concept of Access Specifiers in JAVA. 

For more such content subscribe to our YouTube channel – and follow us on facebook – 
Happy programming !!  

1 thought on “Access Specifiers In JAVA

  1. Thank you for your whole work on this site. Betty enjoys going through investigations and it’s easy to see why. We learn all of the dynamic manner you present very helpful secrets on the web site and as well as welcome contribution from the others on this theme then our princess has always been being taught a whole lot. Enjoy the rest of the year. You have been performing a really good job.

Leave a Reply

Your email address will not be published. Required fields are marked *