Chemistry, asked by ayushdutta26, 10 months ago

Define Encapsulation in java​

Answers

Answered by Aisw
1

Answer:

Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit.

It helps in protecting the data members ,

as the data members can only be accessed with the help of the function members.

I hope it helped.......

Please mark as brainliest answer.......

Answered by guddudbg74gmailcom
0

Answer:

Encapsulation is one of the four fundamental OOP concepts. The other three are inheritance, polymorphism, and abstraction.

Encapsulation in Java is a mechanism of wrapping the data (variables) and code acting on the data (methods) together as a single unit. In encapsulation, the variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class. Therefore, it is also known as data hiding.

To achieve encapsulation in Java −

Declare the variables of a class as private.

Provide public setter and getter methods to modify and view the variables values.

Similar questions