juniorOOP

What are access modifiers in OOP?

Updated May 17, 2026

Short answer

Access modifiers control visibility of class members.

Deep explanation

They define whether properties/methods are public, private, or protected to enforce encapsulation.

Real-world example

Bank systems restricting account balance access.

Common mistakes

  • Using public fields excessively.

Follow-up questions

  • What is protected access?
  • Why use private fields?

More OOP interview questions

View all →