Professional Documents
Culture Documents
5.B
There are 4 types of access protection available for packages & their implication.
- Private
- Protected
- Public
- Default
Private:
In this variable & class are declared private, such that they can’t be access
outside the class. similarly packages with private data members also can’t
called in different package
Example code:
Protected:
In this variable & class are protected, such that they can be access within
the same package & the following sub-classes
Example code:
Default:
In this variable & class are not given any access modifiers, such that they
can be access from only same package .like protected but not from sub-
classes
Example code: