Wednesday, August 1, 2007

Abstract Classes Vs Interfaces

If we are developing some application in which an entity can have more than one implementation, then it is a good practise to use interfaces and implement classes using interfaces.

If some of the functionality of an entity is already known and other methods can have different
implementations, then creating an abstract class is better.

All the methods declared in Interfaces are implicitly abstract. An Abstract class can have
one or more abstract methods as well as concrete methods having implementations.
Interfaces can't have methods that have implementations.

You can implement any number of classes but you can't extends more than class at a time.

We cannot create object of Interface but we can create object of Abstract class.

These are few basic differences between Abstract Classes and Interfaces.

Regards,
Tausif Khan, Nagpur

No comments: