Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Search Your Question

Monday, May 5, 2008

What is encapsulation ? Give an example?

Encapsulation is the ability to hide the internal workings of an object's behavior and its data.

For instance, let's say we have a object named Car and this object has a method named run(). When you create an instance of a Car object and call its run() method you are not worried about what happens to accomplish this, you just want to make sure the state of the Car is changed to 'running' afterwards.

This kind of behavior hiding is encapsulation and it makes programming much easier.

No comments:

Archives