Wednesday, March 25, 2009

Access modifiers in JAVA

In JAVA access specifiers are public, private, protected and default. Java also defines a

default access level. protected applies only when inheritance is involved , and by default any class will be public within the package . The other access specifiers are described next.
Let’s begin by defining public and private. When a member of a class is modified
by the public specifier, then that member can be accessed by any other code. 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 its own package, but cannot be accessed outside of
its package.

No comments:

Post a Comment

Thanks for your opinion....