What are Access specifiers in java

Access specifiers in java
 
   Specifiers which are used to  mention the accessibility of the class/variables/methods are access specifiers.


Types of Access specifiers:

  i]. public                                      - Accessible everywhere
                                                         a] class
                                                         b] subclass within same package/different package
                                                         c] other packages

 ii] protected                                 - Accessible inside in the following places
                                                        a] class
                                                        b] subclass withing same package/different package

iii] default [No access specifier] -  Accessible within the package ..i.e
                                                          a]class
                                                          b] subclass withing same package

iv] private                                    - Accessible only within the class


Table demonstration of Access specifiers for easy understanding.





Will discuss about packages in upcoming posts.
Previous
Next Post »