Monday 17 July 2017

Abstraction Vs Encapsulation

Abstraction Encapsulation
Hides the implementation details of the methods provides a base to variations in the application which can grow over period of time. Hides the private data elements of the class and express only the required things to the client.
In abstract classes some methods can have implementation. All methods, properties in interfaces are empty. They are simple signature.
Abstract classes are used when we want to share common functionality in parent child relationship. Interfaces are used to define the contract, enforced standardization, decoupling and dynamic polymirphism.
We can declare variables. In interface we cannot declare variables.
Abstract classes are inherited. Interface are implemented.
Class only inherits one abstract class. Class may have several interfaces.
Abstract class can contain access modifier. Interface can not have access modifiers, everything is public.
Fast. Require more time to find actual method.

No comments:

Post a Comment