Start learning 50% faster. Sign in now
Encapsulation is one of the core principles of Object-Oriented Programming (OOP). It refers to the concept of bundling the data (attributes) and the methods (functions) that operate on the data into a single unit, or object, and restricting access to some of the object's components. This is typically achieved by using access modifiers such as private , protected , and public to control how the object's data can be accessed or modified. The key idea is to expose only the necessary functionalities (via public methods) while keeping the implementation details hidden.