Access modifiers in java used to set the accessibility (visibility) of the classes, interfaces, variables, methods, member variables and setter/getter methods.

The below table will show the visibility or accessibility of the classes or its members.

Access ModifierClassPackageSub ClassOutside world
PrivateYNNN
default – No KeywordYYNN
ProtectedYYYN
PublicYYYY

Related Posts

Leave a Reply

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