Encapsulation

November 12, 2008

Encapsulation refers to an object hiding its attributes behind its operations.

 

For more information:

It seals the attributes in a capsule, with operations on the edge.

Hidden attributes are said to be private.

 

 

Way to think of encapsulation is to imagine that objects are courteous to one another. If you wanted to borrow some money from a colleague to buy food in the staff canteen, you wouldn’t grab their wallet and look through it to see if they had enough cash.

Instead, you would ask them whether they could lend you some money and they would look

in their own wallet.