Encapsulation in Java.

Encapsulation in Java is a mechanism of wrapping (methods) code and data (variables) together into a single unit.

Code :