Access Modifiers in Java
There are two types of modifiers in java
1.Access modifiers
2.Non-access modifiers.
The access modifiers in java specifies accessibility (scope) of a data member, method, constructor or class.
There are 4 types of java access modifiers:
- Default : If you don't use any modifier, it is treated as default bydefault. The default modifier is accessible only within package.
- Public : The public access modifier is accessible everywhere (Outside Package and Class).
- Private : The private access modifier is accessible only within class.
- Protected : The protected access modifier is accessible within package and outside the package but through inheritance only.the protected access modifier can be applied on the data member, method and constructor. It can't be applied on the class.
There are many non-access modifiers such as static, abstract, synchronized, native, volatile, transient etc.
Click for example of access modifier :
pick for you :
- Generics Class and Methods
- String and String builder and String Buffer
- Linked Hash Set
- Linked Hash Map
- Exception Handling
- Array Class and Array List
- Important Programs
- Searching
- Sorting
- Array Sorting
No comments:
Post a Comment