• Networking
  • Programming
  • DBMS
  • Operating System
  • Internet
  • Hardware
  • Software

Tech Differences

Know the Technical Differences

Difference Between Abstraction and Encapsulation

Abstraction and Encapsulation newAbstraction is a process of collecting important information which will create a base for building up a complex system. Encapsulation is a process of making a complex system easier to handle for an end-user, without worrying about its internal complexities.

The basic difference between “abstraction” and “encapsulation” is that abstraction focuses on “identifying the necessary components for building a system” whereas, encapsulation focuses on “hiding the internal complexities of a system”.

Content: Abstraction Vs Encapsulation

  1. Comparison Chart
  2. Definition
  3. Key Differences
  4. Conclusion

Comparison Chart

Basis for Comparison AbstractionEncapsulation
BasicShows, what elements are necessary to build a system.Hides the complexity of a system.
ApplicationDuring 'design level'.During 'Implementation level'.
FocusFocus is on "what" should be doneFocus is on "how" it should be done.
AchievedAchieved through encapsulation.Achieved through making the members of a class as 'private'.
ExampleThe GUI of a mobile phone, it has some icons to click on, which on click perform the specific function.After the icon is clicked, the end user has no idea regarding its implementation details

Definition of Abstraction

Abstraction is a mechanism of extracting the essential elements for the creation of a system, without its implementation details. In abstraction, we have to focus only on what is to be done instead of how it should be done. Abstraction is a thought process; it solves the problem at the design level.

Hierarchical classification helps us to manage a complex abstraction. It allows us to break a complex system into some manageable pieces and create a layered semantics. Moreover, it is a “generalization”. Let’s, take an example of a ‘Bike’, it is made of a number of subsystems such as engine, brakes, lights, sound system, seat and much more, which when assembled creates an object ‘bike’.

The ‘brake’ which is a subsystem of a bike can further be classified as front wheel brake and back wheel brake, but in general, we view all subsystem as brakes. So, we have to manage the complex system by hierarchical classification, which helps us to find out what are the essential elements which will be required to create a system.

So, abstraction is nothing but generalizing “what elements are essential for creating a system”, i.e. picking up the important ones only.

Definition of Encapsulation

Encapsulation is an essential feature of object-oriented programming. It is a mechanism that binds data and code together and also keeps them safe from the outside interference. In simple words, encapsulation hides the complexity of a system, as the keyword here is “data hiding”.

It is like a protective wrapper that hides the data and code inside the class, being accessed by the other code which is defined outside the class and the member function/method which are not the members of that class.

When “data” and code that operates on that data, are linked in a class, the objects of the class are created. The access to the components of the object is restricted by a well-defined interface called access specifier. There are three access specifiers in C++ and Java; they are public, private, protected.

The encapsulation is particularly achieved by making the data and code, that operates on the data, as private. The private members of the class are unable to access by the code defined outside the class. It helps in preventing the misuse of secured data whereas it also hides the complexity of the code.

Let’s take an example of a mobile phone. In a mobile phone, you can perform many functions such as clicking a picture, recording a video/audio, sending a message, access the internet and much more. You consider all these as the features of a mobile phone. But, the end user doesn’t need to know the internal complexity of these features, before using these applications, nor you need to change the functionality of any of the feature.

So, in this way, the encapsulation hides the complexity and also prevent the misuse of the data.

Key Differences Between Abstraction and Encapsulation

  1. Abstraction focuses on elements that are necessary to build a system whereas, the encapsulation focuses on hiding the complexity of the system.
  2. The abstraction is performed during the design level of a system. On the other hand, encapsulation is performed the system is being implemented.
  3. Abstractions main motive is, what is to be done to build a system. Encapsulations main motive is, how it should be done to build a system.
  4. Abstraction is achieved by encapsulation whereas, the encapsulation is achieved by making the elements of the system private.

Conclusion

Abstraction and encapsulation both are the essential features of OOP. A good encapsulation can achieve a good abstraction.

Related Differences:

  1. Difference Between Stack and Queue
  2. Difference Between 3G and 4G Technology
  3. Difference Between Array and Linked List
  4. Difference Between Data Hiding and Encapsulation
  5. Difference Between Abstraction and Data Hiding

Comments

  1. victor richard says

    November 26, 2019 at 9:47 am

    The differences are well exposed and explained. Thank you.

    Reply
  2. Janani says

    April 27, 2020 at 9:50 am

    Very clear explaination. Thankyou.

    Reply
  3. Meena says

    September 30, 2021 at 12:31 pm

    Thank you for the clear points

    Reply
  4. unknown says

    December 10, 2021 at 8:22 am

    Thanks for this article

    Reply

Leave a Reply Cancel reply

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

Top 10 Differences

  • Difference Between OLTP and OLAP
  • Difference Between while and do-while Loop
  • Difference Between Guided and Unguided Media
  • Difference Between Preemptive and Non-Preemptive Scheduling in OS
  • Difference Between LAN, MAN and WAN
  • Difference Between if-else and switch
  • Difference Between dispose() and finalize() in C#
  • Difference Between for and while loop
  • Difference Between View and Materialized View
  • Difference Between Server-side Scripting and Client-side Scripting

Recent Addition

  • Difference Between Java and Python
  • Difference Between PHP and HTML
  • Difference Between GPS and GNSS 
  • Difference Between Virtualization and Containerization
  • Difference Between Storage and Memory

Categories

  • Artificial Intelligence
  • DBMS
  • Hardware
  • Internet
  • Networking
  • Operating System
  • Programming
  • Software

Copyright © 2025 · Tech Differences · Contact Us · About Us · Privacy