Friday, September 6, 2013

ACCESS MODIFIERS IN JAVA

WHAT ARE ACCESS MODIFIERS IN JAVA ?

Access modifiers are the special keywords which when applied provide different types of access to the content of the class. By content I mean, the data members/ fields and methods defined in the class. There might come situations where we don't want other classes to access the fields or methods or the class and some situations where we want all the elements of the class to be accessed by any other class.
Therefore, to provide different kinds of access for different kind of situations, Java has Access Modifiers, there are 3 kind of Access Modifiers :
1. public
2. private
3. protected

WHEN 'public' ACCESS MODIFIER IS USED :





No comments:

Post a Comment