0 votes
in JAVA by
Select the best from following refers to the wrapping of data and its functionality into a single individual entity?

(i) Modularity

(ii) Abstraction

(iii) Encapsulation

(iv) None of the above

1 Answer

0 votes
by

(iii) Encapsulation

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.

Related questions

0 votes
asked Mar 20, 2023 in Clustering - The Data Ensemble by john ganales
0 votes
asked Jan 24, 2021 in JAVA by rajeshsharma
...