Encapsulation VS Abstraction

This is a bit confusing while both are like same, because the definition where abstraction is showing only necessary and the encapsulation is hiding complexity.

It seems that they are similar, but actually they’re not, here’s how they differ:

Abstraction

  1. Abstraction is a concept of hiding mechanism.
  2. Only showing those parts which is necessary.
  3. It is a thought process that is solved at design level.

Encapsulation:

  1. Encapsulation is the implementation of that concept.
  2. Hiding complexity.
  3. Here it is the actual process of hiding that is solved at class level.

Real world Example:



Refrigerator:

  1. Refrigerator Freezing is a concept. We know only cooling or not cooling (Abstraction).
  2. How it is done user need not to know (Encapsulation).

Mobile Phone:

  1. We operate phone using touch screen (Abstraction). We only need to know its touch which is working or not!.
  2. We don’t know how the internal mechanism of touch responding circuit connection (Encapsulation).
Ebook Download
View all
Learn
View all