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 is one of the fundamental principles of object-oriented programming (OOP). This principle defines how an object can maintain its state (data) and implement its methods (functions), hiding their details from the outside world.

Key Aspects of Encapsulation

Fields (class fields) - data that belong to an object or class. Encapsulation allows these fields to be hidden from direct access, providing access to them only through class methods. In other words - isolation of code.
Methods - functions that are defined in a class. Encapsulation also means that some methods can 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) that allow control over how class fields and methods are accessible 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

How to install Steam on Ubuntu? Installing Steam via the terminal.

meme code
meme code@memecode
24 Jul 11:47

How to change the language in Steam to Ukrainian?

meme code
meme code@memecode
24 Jul 12:01

What is "Vulkan Shader Processing" in Steam?

meme code
meme code@memecode
24 Jul 12:17

How to make Counter-Strike: GO fullscreen in Ubuntu without launching the game?

meme code
meme code@memecode
20 Nov 19:35

How to recover a deleted file (Trix) that was stored on Amazon S3?

meme code
meme code@memecode
29 Nov 08:47

What is the difference between var and let in Javascript?

meme code
meme code@memecode
07 Dec 08:13

Visibility control in Ruby (public, private, and protected)

meme code
meme code@memecode
07 Dec 08:25

What is OOP (object-oriented programming)?

meme code
meme code@memecode
09 Dec 12:00

What is inheritance in Ruby? Examples of bad and good inheritance.

meme code
meme code@memecode
09 Dec 12:15

What is best practice in programming?

meme code
meme code@memecode
09 Dec 12:21

What is polymorphism? An example of using polymorphism in Ruby.

meme code
meme code@memecode
09 Dec 12:46

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

meme code
meme code@memecode