+ 2
What does encapsulation actually includes?
4 Respuestas
+ 11
If you are feeding your dog, you are rarely doing it by chewing the food, then slitting your dog open with a knife, spitting the food in his stomach, and then stitching him back up.
I mean - That's basically how the dog digests his food, right? Yet this sounds nuts, and we use similar reasoning in OOP. An object is an encapsulated thing - methods, properties, internal state, all bundled together - with a clearly defined set of things you are allowed to do. All this internal state is hidden, like in a black box, and you may not mess with it. If you want to feed the dog, place the food in his bowl and call his 'public void eat'-method, and don't try to access his 'private Stomach stomach'.
+ 2
Encapsulation means hiding attributes and functions of a class from outside the class. It is more secure. For example manipulating the value of an attribute will be done just through setter and getter.
+ 1
Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. Data encapsulation led to the important OOP concept of data hiding.
To be simple it is a concept of hiding (or) protecting data!!!
It's a part in data hiding!!!😀😀😀
0
in Encapsulation data members and functions are protected inside the class. just like diffrent chamical compound in a capsule(kind of medicine).Data is the most important thing for any program so it need to protect from unauthorised acess.