Access Modifiers
Access control is nothing but giving control/access over that particular class member.
This can be in various ways namely
1)Public-when a method or a variable is declared as public,it means all other classes regardless of package they belong to, can use them.
2)Private-Members marked as private cannot be accessed anywhere except the class it is declared.
3)Protected-Members which are marked as protected can be accessed anywhere inside the package and also in the classes which inherit that particular class where it is declare.
4)default-Same as protected except it can only be accessed anywhere inside the package but not by the child packages outside the project.
This can be in various ways namely
1)Public-when a method or a variable is declared as public,it means all other classes regardless of package they belong to, can use them.
2)Private-Members marked as private cannot be accessed anywhere except the class it is declared.
3)Protected-Members which are marked as protected can be accessed anywhere inside the package and also in the classes which inherit that particular class where it is declare.
4)default-Same as protected except it can only be accessed anywhere inside the package but not by the child packages outside the project.
Comments
Post a Comment