All original content is created in Ukrainian. Not all content has been translated yet. Some posts may only be available in Ukrainian.Learn more

What is encapsulation in OOP?

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.

24 Jul 11:25

Як встановити Steam в Ubuntu? Встановлення Steam через термінал.

meme code
meme code@memecode
24 Jul 11:47

How to change the language on Steam to Ukrainian?

meme code
meme code@memecode
24 Jul 12:01

What is "Vulkan Shader Processing" on Steam?

meme code
meme code@memecode
24 Jul 12:17

How to make Counter-Strike: GO in Ubuntu full screen without starting the game?

meme code
meme code@memecode
20 Nov 19:35

Як відновити видалений файл (Trix), який зберігався на Amazon S3?

meme code
meme code@memecode
29 Nov 08:47

Чим відрізняється var від let в Javascript?

meme code
meme code@memecode
07 Dec 08:13

Контроль видимості в Ruby (public, private і protected)

meme code
meme code@memecode
07 Dec 08:25

Що таке ООП (об'єктно-орієнтоване програмування)?

meme code
meme code@memecode
09 Dec 12:00

Що таке наслідування в Ruby? Приклади поганого та гарного наслідування.

meme code
meme code@memecode
09 Dec 12:15

What is best practice in programming?

meme code
meme code@memecode
09 Dec 12:21

Що таке поліморфізм? Приклад використання поліморфізму в Ruby.

meme code
meme code@memecode
09 Dec 12:46

Що таке патерн/шаблон проєктування?

meme code
meme code@memecode