Exam 15 - 16 03 Flashcards
1
Q
- public class ModuloCounter {
- private int count;
- private int modulo;
4. - public ModuloCounter() { count = 0; modulo = 10; }
6. - public int getCount() { return count; }
8. - public void setCount(int val) { count = val; }
b) Explain how the principle of encapsulation has been achieved in
the implementation of this class, and state a benefit of this.
A
Benefits: Encapsulation promotes maintenance
Code changes can be made independently
Increases usability