Encapsulation in JAVA
Jul 11, 2026
Encapsulation
Without encapsulation:
Press enter or click to view image in full size![]()
Press enter or click to view image in full size![]()
Anyone can update these field so we need to put boundation.
Get ChiragMaini’s stories in your inbox
Join Medium for free to get updates from this writer.
How to achieve encapsulation?
- Make all properties as private so that they can be accessible only within that class.
Press enter or click to view image in full size![]()
Press enter or click to view image in full size![]()
Task: Create a bank balance system






