JAVA Modifier

Public Keyword is an access modifier , meaning that it is used to set the access level for classes , attributes, methods and constructors.

We divide modifiers in to two groups

  1. Access Modifier
  2. Non Access Modifier

Access Modifier :-

Controls the access level

Non Access Modifier :-

Do not control Access level but provides functionality

final , abstract ,static ,native ,volatile ,transient, synchronized

Public :-

The class is accessible by an any other class within th class, outside the class, within the package, outside the package.

Default :-

The class is only accessible by classes in the same package.

if you do not specify it will be default.

Private:-

This code is only Accessible within the declared class.

it can not be accessed from outside the class.

Protected :-

The code is accessible in the same package and subclasses.

if you do not make the child class, it can not be accessed from outside the package.