Encapsulation is one of the 4 main OOP principles.
It protects the class data from access outside the class body.
Result:
Explanation:
line 36
the code won't compile. A direct access
to private members cannot be done outside the class body.Output:
All members are accessible outside the class body.