0

Encapsulation is defined as the process of wrapping code and data together into a single unit.

What does wrapping code and data mean? Encapsulation is giving restricted access to the user right?

8/10/2019 4:52:29 AM

Geek

1 Answer

New Answer

+4

Geek Wrapping means defining member variables and methods to operate on those variables. Java force OOPS, and no data or method can exist outside the class, hence wrapping code and data is obvious thing and you may not see it as something separate, something different. But take example of C++ one can write a C++ program by defining methods and variables in global space creating mess, but all code and data can be abstracted out and encapsulated in the form of various classes. Access modifiers (public, protected, private) are used to control access to the resource(member field).