Access control

Encapsulation links data with the code that manipulates it. However encapsulation provides another important attribute: access control. Through encapsulation, you can control what parts of a program can access the members of a class.

You can define access control as the methods by which interactions with resources are limited to collections of users or programs for the purpose of enforcing integrity, confidentiality, or availability constraints.

How a member can be accessed is determined by the access specifier that modifies its declaraion. Java supplies a rich set of access specifiers. Some acpects of access control are related mostly to inheritance or packages.

Java's access specifiers are public, private and protected. Java also defines a default access level.

When a member of a class is modified by the public specifier then that member can be accesed by any other code in your program.

When a member of a class is specified as private then that member can only be accessed by other members of its class.

When no access specifier is used then by default the member of a class is public within it's own package but canot be accessed outside of its package.

When a member of a class is specified as protected it is available to all classes in the same package and also available to all subclasses of the class that owns the protected feature.This access is provided even to subclasses that reside in a different package from the class that owns the protected feature.

abstract class
abstract factory
abstract method
access control
application server
Use of this website constitutes acceptance of the AllAppLabs.com Terms and Conditions