Problem Statement
What are the risks or drawbacks of improper encapsulation, and how can they be mitigated?
Explanation
If a class exposes its internal data directly (e.g., public fields), it opens the door to invalid state, brittle code and tight coupling. Changes to internal representation ripple across clients. To mitigate this, use access modifiers, provide well-defined interfaces, favour immutability, validate inputs in setters and keep internal logic behind private or protected methods. Designing classes with clear separation of concerns and using API contracts helps maintain encapsulation and system robustness.