Access Specifiers
Access specifiers are used to set the visibility(scope) for class or interface or members.
There are following access specifiers:
- Private.
- Default/friendly.
- Protected.
- Public.
Private
(i) Private members are declared with a keyword private.
(ii) Private members are available only within the class.
(iii) Private members can not be inherited.
(iv) private keywords can be used for variables, methods or nested class.
(v) Private members access within a class.
(vi) private keyword can use for constructor also.
Default
(i) Default members are declare with no access specifier keyword.
(ii) Default members can be accessible within a package.
Protected
(i) Protected members are declared with the keyword protected.
(ii) Protected members can be access within a package also outside the package through inheritance.
Public
(i) Public members are declared with keyword public.
(ii) Public members can be accessed within a package and outside a package.
0 Comment(s)