0% found this document useful (0 votes)
2 views3 pages

Java 1 (Access Specifiers)

Uploaded by

Ayasha Choudhary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Java 1 (Access Specifiers)

Uploaded by

Ayasha Choudhary
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

BCA : 5TH SEM

BCA-S301T : JAVA PROGRAMMING AND DYNAMIC WEBPAGE DESIGN


RAM GOPAL GUPTA
ASSOCIATE PROFESSOR
DISCLAIMER

Contents of the tutorial, shown image(s) (if shown here) and movie(s) (if shown here)
are just compilation of research work/creation of various authors/organizations.
Contents are collected from various research papers, reports, books, websites and other
sources.

BCA-S301T : JAVA PROGRAMMING AND DYNAMIC WEBPAGE DESIGN


UNIT-1
ACCESS SPECIFIERS IN JAVA

Types Of Access Modifiers/ Specifiers In Java


Java provides four types of access specifiers that we can use with classes and other entities.

These are:
1. Private: When an entity is private, then this entity cannot be accessed outside the class. A
private entity can only be accessible from within the class.
2. Default: Whenever a specific access level is not specified, then it is assumed to be ‘default’.
The scope of the default level is within the package.
3. Protected: The protected access level has a scope that is within the package. A protected
entity is also accessible outside the package through inherited class or child class.
4. Public: This is the most common access level and whenever the public access specifier is
used with an entity that particular entity is accessible throughout from within or outside the
class, within or outside the package, etc.

We can summarize the access modifiers in the following table.

Access Inside Inside Outside package Outside


Specifier Class Package subclass package

Private Yes No No No

Default Yes Yes No No

Protected Yes Yes Yes No

Public Yes Yes Yes Yes

BCA-S301T : JAVA PROGRAMMING AND DYNAMIC WEBPAGE DESIGN

You might also like