What is difference between public/private and protected and default in Java?

Differences. First and important difference is the accessibility i.e. anything public is accessible to anywhere , anything private is only accessible in the class they are declared , anything protected is accessible outside the package but only to child classes and default is accessible only inside the package.

Sizin İçin Seçtik  Which of the following access modifier can be accessed within a class private protected public?

Leave a Reply

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