Abstraction |
Encapsulation |
Abstraction is a general concept formed by extracting common features from specific examples or the act of withdrawing or removing something unnecessary.
|
Encapsulation is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
|
You can use abstraction using interface and abstract class.
|
You can implement encapsulation using access modifiers (public , protected , and private ).
|
Abstraction solves the problem in design level.
|
Encapsulation solves the problem in implementation level.
|
For simplicity, abstraction means hiding implementation using abstract class and interface.
|
For simplicity, encapsulation means hiding data using getters and setters.
|