Java
Supports 4 access specifiers: public, private, protected and
default(no modifier). If program not specifies any access modifier,
then default assumed.
Modifier | Class | Package | subclass | Global |
public | Y | Y | Y | Y |
protected | Y | Y | Y | N |
no modifier | Y | Y | N | N |
private | Y | N | N | N |
Public
data is accessible from any where i.e, from within the package or
outside the package
protected
data accessible from within the package and the sub classes of the
class.
Data
with no modifiers accessible from with in the package.
Private
data accessible from with in the class.
No comments:
Post a Comment