ICSE Class 10 Computer Applications
Question 4 of 16
Encapsulation and Inheritance — Question 4
Back to all questions 4
Question Question 4
Why is it a good idea to make all instance variables private?
It is a good idea to make all instance variables private because:
- It hides the implementation details of the class from other objects, which makes it easier to change the implementation without affecting the rest of the system.
- It provides encapsulation as the class defines a clear and well-defined interface for interacting with its state.
- It protects the state of the object by preventing external objects from modifying the state in an unintended way.