encapsulation in java project code example

Example 1: what is encapsulation java

Encapsulation in Java is a mechanism to wrap up variables and methods together
as a single unit. It is the process of hiding information details and protecting
data and behavior of the object. It is one of the four important OOP concepts. 
 The encapsulate class is easy to test, so it is also better for unit testing.

Example 2: encapsulation in java

1-ENCAPSULATION: We can hide direct access to data by using
private key and we can access private data by using getter and
setter method.

Tags:

Java Example