Access
Specifiers:-
Access specifier is
a key word that specifies how to access or read the member of a class or the
class itself.
There
are 4 access specifiers.
1)
Private: - private members are
not available outside the class.
2)
Public: - public members are
available anywhere outside the class.
3)
Default: -Default members are
available outside the class.
Note: - If the user does not
use any access specifier then java compiler uses default specifier.
4)
Protected: - protected members
are available in class and sub class.
Private can not be used
before the class name. In type1 initialization, if the instance variables are
declared as private, they are not available to other classes.
No comments:
Post a Comment