Data Abstraction and Encapsulation

Dec 3 • Notes • 4961 Views • No Comments on Data Abstraction and Encapsulation


1.     Data abstraction is actually the phenomenon of hiding the unnecessary details from the user. It can be defined as the phenomenon of presenting the essential features before the user without displaying the background details and explanations.
2.     Data abstraction by its name refers to abstract the process and the internal information.
3.     Abstraction is actually the process by which data and programs are defined with a representation which is similar in form to its meaning (semantics), while hiding away the implementation details.
4.     Abstraction tries to reduce and factor out the details so that the programmer can focus on a few concepts at a time.
5.     Data abstraction is a programming (and design) technique that relies on the separation of interface and implementation.


Data AbstractionLet us take one real life example of a TV, which you can turn on and off, change the channel, adjust the volume, add external components such as speakers, VCRs, and DVD players, etc. BUT do you know about its internal details, that is, how it receives signals over the air or through a cable, how it translates them, finally displays them on the screen, etc.? I don’t think so. If you are a normal person who is not an electronics and communication / telecommunication employee or student, then you definitely will not know about it. This is abstraction as all the working details are actually unnecessary to you. You just need to watch the programs on TV and if anything goes wrong, the specialized persons are there to handle it.

As mentioned above, the same thing is with the programs. A general user just needs to use it. It would be immaterial for them to know how the program works, what all calculations is it doing, etc.


  • Data EncapsulationEncapsulation is one of the four fundamental Object Oriented Programming (OOP) concepts. The other three being Abstraction, Inheritance, and Polymorphism.
  • Encapsulation is defined as wrapping up of data and information together under one name along with protecting the information from the outside world.
  • It is actually the technique of making the fields in a class private and providing access to those fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. For this reason, encapsulation is also referred to as data hiding.
  • Encapsulation can also be described as a protective barrier that prevents the code and data being randomly accessed and modified by the other codes defined outside the class. Access to the data and code is tightly controlled by an interface.
  • The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this feature Encapsulation gives maintainability, flexibility and extensibility to our code.

I hope I was able to clear this topic. If you still have any doubt or query regarding this topic, or have any suggestions for us, please share it with us in the comment box below.

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

« »