What are the different types of access modifiers in Java?

Java has four access modifiers :

  1. Private – Accessible only within the same class.
  2. Default (No Modifier) – Accessible within the same package.
  3. Protected – Accessible within the same package and by subclasses.
  4. Public – Accessible from anywhere in the project.