|
Difference between abstraction and encapsulation
-
Abstraction is a concept in object-oriented programming that "shows" only the most important features while "hiding" the rest. The main purpose of abstraction is hiding the unnecessary details from the users.
-
Encapsulation is a technique for making a complex system more user-friendly. The user does not need to be concerned about the system's internal details or complexities. Encapsulation is a process of combining data and the code that manipulates it into a single entity.
-
Abstract classes and interfaces can be used to implement abstraction, Encapsulation, on the other hand, can be implemented using access modifiers such as private, protected, and public.
-
Abstraction emphasizes what should be done, whereas Encapsulation emphasizes how it should be done.
-
Abstraction solves problems at the level of design, whereas encapsulation solves problems at the level of implementation.
|