Need of Encapsulation


Need of Encapsulation

How Data Wrap? 

Encapsulation is used for combine a data and function into a single unit. that cause no on

Encapsulation is most fundamental unit in the OOPS’. it is the method to combine data and the functions that use that data into a single unit. When data and functions wrap into a single unit(called class) is known as Encapsulation.
this is the way to access a data is provided by the functions(which combine with along the data). The functions which provide to access a data is called a member function. Without a member function data cannot be access directly. for read a data item in an object, always call a member function in the will read the item and return a value. data can’t be access directly. it always present in the hidden and its function into a single entity said to be encapsulation.

Example- In a company, there are so many departments, sales, account, payroll, purchase, production.each have own member function to maintain its data. if an employee from account want to know how much raw material has been purchased for a after two months.that time production dept employee not allowed him to check purchase dept(data file). than some employee of the’purchase’ will check data on purchase data files .this implies that data is only accessed by purchased team not from outside members.’department data’ and ‘department employee’ are encapsuled into a single entity(the department).classes use the concept of data abstraction, they are called Abstract Data Type(ADT).

These can create a object of there own type so called data type.
Encapsulation is the way to implement data abstraction. encapsulation hide the detail of the implementation
of an object. abstraction focuses on the observable behavior of an object and encapsulation focuses on implementation.

Memory boost tips

Leave a Reply

Your email address will not be published. Required fields are marked *