There are 4 access specifiers :
1) private - private fields, methods will be accessible within the same class.
2) public - public fields, methods can be accessed from anywhere.
3) protected - protected methods and fields can only be accessed within the same class to which the methods and fields belong, within its subclasses, and within classes of the same package.
4) default - If you do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs, but not from outside this package.
1) private - private fields, methods will be accessible within the same class.
2) public - public fields, methods can be accessed from anywhere.
3) protected - protected methods and fields can only be accessed within the same class to which the methods and fields belong, within its subclasses, and within classes of the same package.
4) default - If you do not set access to specific level, then such a class, method, or field will be accessible from inside the same package to which the class, method, or field belongs, but not from outside this package.
No comments:
Post a Comment