Skills101
← Tech dictionary

Programming & OOP

What is Encapsulation?

Encapsulation means keeping an object’s data private and allowing changes only through its methods, so the object can protect its own rules. It hides internal details behind a public interface.

Example

A BankAccount class keeps balance private and only changes it through deposit() and withdraw(), which reject negative amounts.

Learn it properlyOOP tutorials — free, with diagrams, quizzes and a certificate

Related terms