What is encapsulation?

Showing Answers 1 - 1 of 1 Answers

samiksc

  • Jan 25th, 2006
 

Encapsulation is a OOPs principle which states that all data and methods operating on that data be bundled together, and only relevant data should be shown to the user of the class (object of the class created outside the class).

This is why we write classes which contain the data and methods which are logically related. Data is given public access only if required. Generally all data is private or protected and is made available to outside objects by means of properties. Use of properties ensures that the data is validated before it is saved. Also some portion of data can be made read only by removing set accessor.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions