Table of contentsClick link to navigate to the desired location
This content has been automatically translated from Ukrainian.
Encapsulation (encapsulation) it is one of the main principles of object-oriented programming (OOP). This principle defines how an object can store its state (data) and implement its methods (functions), hiding their details from the outside world.
Main aspects of encapsulation
Fields (class fields /class fields) - data belonging to an object or class. Encapsulation allows you to hide these fields from direct access, providing access to them only through class methods. In other words - code isolation.
Methods (methods) - functions that are defined in the class. Encapsulation also means that some methods may be hidden or protected from direct use, providing only limited access to them.
Access modifiers - OOP programming languages provide access modifiers (for example) public, private, protected), which allow you to control how fields and methods of the class are available to other classes. This provides a degree of isolation and data protection.
- public: open (English: "public").
- private: private (English: "private").
- protected: protected (English: "protected").
This post doesn't have any additions from the author yet.