Question
Which is the advantage of encapsulation?
- A. Only public methods are needed.
- B. No exceptions need to be thrown from any method.
- C. Making the class final causes no consequential changes to other code.
- D. It changes the implementation without changing the interface and causes no consequential changes to other code.
- E. It changes the interface without changing the implementation and causes no consequential changes to other code.
D.
Note
When a class is properly encapsulated, it is possible to change the class's implementation without changing its interface.
Implementation changes do not affect other classes which abide by this interface.
PreviousNextRelated