Monday, July 4, 2011

Java Questions -1

What is the difference between private, protected, and public?

These keywords are for allowing privileges to components such as java methods and variables.
Public: accessible to all classes
Private: accessible only to the class to which they belong
Protected: accessible to the class to which they belong and any subclasses.
Access specifies are keywords that determine the type of access to the member of a class. These are:
* Public
* Protected
* Private
* Defaults

No comments: