Access Modifiersmodifiers are there to restrict access at several levellevels.
Public : itIt is basically as simple as you can access from any class eitherwhether that is in same package or notnot.
To access if you are in same package you can access directly, but if you are in otheranother package then you can create an object of the class.
Default : itIt is accessible in the same package from any of the class of package.
toTo access you can create an object of the class. butBut you can not access this variable outside of the package.
Protected : you can access variables in same package as well as subclass in any other package. so basically it is default + Inherited behavior.
To access protected field defined in base class you can create object of child class.
Private : it can be access in same class.
In non-static methods you can access directly because of this reference (also in constructors)but to access in static methods you need to create object of the class.