Persistent Systems Interview Question

What are the differences between the public, private, protected, and default (package-private) access modifiers in Java?

Interview Answer

Anonymous

Mar 6, 2025

public allows access from any class, private restricts access to the declaring class, protected allows access to subclasses and classes in the same package, and default access is accessible only within the same package