Encapsulation

Encapsulation bundles data (attributes) and the methods (functions) that operate on that data within a single unit, an object.

It hides the internal implementation details of an object from the outside world, exposing only a public interface for interaction.

This promotes data security, prevents unintended modifications, and allows for changes to the internal implementation without affecting other parts of the code.


Links to this note