Java uses access modifiers to determine which parts of the code can be accessible to any other part of the code or any user or members. This provides increased security to sensitive code.
There are 4 access modifiers in java:
Public
Protected
Default
Private
Here is a chart that shows the difference between these access modifiers:

Comments