D.2.4+Explain+the+advantages+of+encapsulation

Encapsulation has several advantages, they are:  **1.** Encapsulated Code is more flexible and easy to change with new requirements.  **2.** Encapsulation in Java makes unit testing easy.  **3.** Encapsulation in Java allows you to control who can access what.  **4.** Encapsulation also helps to write unchageable classes or objects.  **5**. Encapsulation reduce coupling of modules and increase cohesion inside a module because all piece of one thing  are encapsulated in one place.  **6.** Encapsulation allows you to change one part of code without affecting other part of code.

Encapsulation makes it possible to separate an objects implementation from its behavior to restrict access to its internal data. This restriction allows certain details of an objects behavior to be hidden. It allows us to create a “black box” and protects an objects internal state from corruption by its clients.

rss url="https://groups.diigo.com/group/comp_sci/rss/tag/D.2.4" link="true" number="10"