Explain the Concept of Data Abstraction and Data Encapsulation in Object Oriented Programming (OOPS)
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
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
- What are objects ? What is common between all objects of a class ?
- What are classes ? How are they defined ?
- State all the class access modifiers and explain each one of them
- What are static Data and Static Member Functions in C++ ?
- What are Templates in C++ ? How are Templates declared and used ?


