Q:

What is encapsulation? Why is it useful

0

What is encapsulation? Why is it useful?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Encapsulation enforces the separation between interface and implementation in a class via access specifiers. Encapsulation provides some advantages:

  - A class that is encapsulated hides its implementation to the user of the class, thus the user need not know how the class works, they can regard the class as a type (like a built-in type) instead.

  - User code cannot inadvertently corrupt the state of an encapsulated object.

  - The implementation of an encapsulated class can change over time without requiring changes in user code.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now