Which class is super class of every class

Difference between public private protected default Access Specifiers

OR
What is the difference between public, private, protected and default Access Specifiers?

Answer : Through encapsulation you can control which part will have access to the member of a class. In java access specifiers are private, protected and public and it also defines default access level. Below table shows how these variable control access when define i the class:

Access Levels

ModifierClassPackageSubclassWorld
publicYYYY
protectedYYYN
no modifierYYNN
privateYNNN

Leave a Reply

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