Explain the Concept of Data Abstraction and Data Encapsulation in Object Oriented Programming (OOPS)

October 28, 2007 · Filed Under C++ Questions, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

Data encapsulation: the wrapping up of data and functions that act upon that data in a single unit is termed as data encapsulation. It binds together both the data and code and thus keeps both safe from the outside world. The data and the code to manipulate the data are combined in such a way that a black box is created which is self contained and modular. This box is termed as a class in object oriented terminology. Within a class the code or the data can be private or public. If it is private then these cannot be accessed by the outside world whereas public means that the code and the data is accessible to everyone. Typically the data is private and the methods are an interface to the private elements of the object.

Data abstraction: The term data abstraction is similar to data encapsulation. All the data and the methods that make sense to the objects of a class that is been designed need to be a part of the class. All unnecessary details should be left behind. E.g. when designing a class to represent a student we need data elements such as student no, student name, marks, grade, etc. If we now design a class representing a cricket player we need details like no of centuries, striking rate, no of matches played, etc. It will not make sense to add the player’s marks, grades which are applicable to a student class to this player class. The classes designed in object oriented language are also termed as User defined data types (UDT).

Related Articles


Get Latest JobsAdda.com Jobs, news & updates  via Email