There are 2 types of modifiers in java:
- Access modifiers
- Non-access modifiers
Default fields are accessible within the same package.
you can not use your default fields outside the package.
when you declare any field with prefix private then it is called private fields.
Private fields are accessible within the same class.
when you declare any field with prefix protected then it is called protected fields.
Protected fields are accessible only through inheritance.
when you declare any field with prefix public then it is called public fields.
Public fields are accessible Everywhere.