In 10 carts

Price: ₹ 142.000

Original Price: ₹ 487.000

50% off
New markdown! Biggest sale in 60+ days

Encapsulation in java: Encapsulation is one of the

You can only make an offer when buying a single item

Add to cart

Encapsulation is one of the fundamental concept of object-oriented programming (OOP) It is widely used for data hiding, it binds the data (variables) and the methods (functions) in a single unit called class. In this guide, we will learn this concept with the help of examples and programs. Note: If you are looking for a In this article, we will learn what is Encapsulation in Java with real-world examples and source code examples. In the encapsulation technique, we declare fields as private in the class to prevent other classes from accessing them directly. The required encapsulated data can be accessed by using public Java getter and setter method. Person class contains both data (name, age) and method (displayInfo()). Everything is inside one unit (class) — this is the essence of encapsulation. Above example is simple encapsulated class, but it does not provide any data hiding. So, to create proper encapsulation, we have to follow some rules which are explained below. 1. Private Variables :

4.9 out of 5

(9852 reviews)

5/5 Item quality
4/5 Shipping
4/5 Customer service
Loading