What is encapsulation in object oriented programming ?
Вставка
- Опубліковано 26 сер 2024
- Encapsulation bundles data (attributes) and methods together inside the wrapper called class.
Similar to capsules where different kind of medicines are are kept together inside the top cover, here data and methods are kept inside top cover called called "class".
To consume medicines inside capsule, first we need to uncover top layer. Similarly here, to access data and methods of class we need to uncover class by creating object for this.
Best explanation of encapsulation ever
Set variable to private and use public getter setter to access data
So sad that this is the understanding of OOP among most people...
great vid
He hides the object