View RSS Feed

Java Object

Controlling Access to Members of a Class

Rate this Entry
by , 04-26-2012 at 04:43 PM (578 Views)
It is determined by the Access level modifier that a particular field or method could be used or invoked by the other classes or not. Access control levels are as following:
  • At the top level, which is package-private or private i.e no explicit modifier.
  • At the member level, this is public, protected, private or package-private i.e. no explicit modifier.



With modifier public, declaration of the class might be done. In that case class becomes visible to classes, everywhere. If no modifier (also named as package private) is present in a class then it’s just visible in its own package.

No modifier or public modifier could also be used at the member level just like it is done at top leveled class. Additional access modifiers are present for the members, which are “protected” & “private”. It is been specified by the private modifiers that members could just be accesses in their class. It is been specified by the protected modifiers that members could be accessed just in their package and also by the class’s subclass which is present in some other package.

Submit "Controlling Access to Members of a Class" to Facebook Submit "Controlling Access to Members of a Class" to Digg Submit "Controlling Access to Members of a Class" to del.icio.us Submit "Controlling Access to Members of a Class" to StumbleUpon Submit "Controlling Access to Members of a Class" to Google

Categories
Tutorial

Comments