Difference Between Abstraction and Encapsulation

Computer ProgrammingProgrammingMiscellaneous

In this post, we will understand the difference between abstraction and encapsulation.

Abstraction

  • It is the process of gaining information.

  • The problems in this technique are solved at the interface level.

  • It helps hide the unwanted details/information.

  • It can be implemented using abstract classes and interfaces.

  • The complexities of the implementation are hidden using interface and abstract class.

  • The abstraction can be performed using objects that are encapsulated within a single module.

Encapsulation

  • It is a method that helps wrap up data into a single module.

  • Problems in encapsulation are solved at the implementation level.

  • The data is hidden using methods such as getters and setters.

  • It helps hide data using a single entity, or using a unit with the help of method that helps protect the information.

  • It can be implemented using access modifiers like public, private and protected.

  • Objects in encapsulation don’t need to be in abstraction.

raja
Published on 24-Mar-2021 13:52:54
Advertisements