Java Encapsulation Encapsulation is one of the four fundamental (inheritance, abstraction, and polymorphism) Object-Oriented Programming concepts. It a kind of mechanism of wrapping data in a single unit. In encapsulation variables of a class are kept hidden from other classes. We use access specifier to make these data private, protected (To make variable private in its child class). And this is known as Data Hiding.

Java Encapsulation Example

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

Java Encapsulation Tutorial

#java #java encapsulation #programming

Java Encapsulation Example | Encapsulation in Java
2.25 GEEK