Saturday, August 11, 2012

ACCESS MODIFIER IN JAVA



There are 4 access modifier in core Java. They are public, private, protected and default.
The table bellow shows the access of class with different modifier








Access Modifier table
     Visibility                                

PUBLIC  
    PROTECTED  DEFAULT PRIVATE
Access from the same class            YES                 YES YES YES
Acces from any class in same package YES YES YES NO
From subclass in same package YES YES YES NO
Access from subclass outside package YES YES through inheritance NO NO
Access from any non subclass outside package YES NO NO NO





No comments:

Post a Comment