0 votes
120 views
in JAVA by (98.9k points)
edited

What are the various access specifiers in Java?

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer

In Java, access specifiers are the keywords which are used to define the access scope of the method, class, or a variable. In Java, there are four access specifiers given below.

  • Public The classes, methods, or variables which are defined as public, can be accessed by any class or method.
  • Protected Protected can be accessed by the class of the same package, or by the sub-class of this class, or within the same class.
  • Default Default are accessible within the package only. By default, all the classes, methods, and variables are of default scope.
  • Private The private class, methods, or variables defined as private can be accessed within the class only.

Related questions

0 votes
1 answer 117 views
asked Aug 9, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 125 views
0 votes
1 answer 114 views
0 votes
1 answer 197 views
asked Jul 20, 2022 in JAVA by Doubtly (98.9k points)
0 votes
1 answer 149 views

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

563 users

...