Saturday, October 9, 2010

Difference between abstract class and interface


ABSTRACT CLASS:
1.An object of abstract class cannot be created as it can contain unimplemented functions.
2)An Abstract class can also contain concrete methods(Non-Abstract).
3)In derived class we can use abstract method by using override keyword.
4) we can't use multiple inheritance in abstract class.
5) Absrtact class can be extended by only one class; Interface can be implemented by more than one class;ie. class can inherit only one abstract class.

6)Abstract classes can inherit interfaces while interfaces cannot inherit abstract classes but class can implement more than one interface.
7) The members of the interface are public with no implementation. Abstract classes can have protected ,static methods, etc.

8)An abstract class can contain fields, constructors, or destructors and implement properties. An interface can not contain fields, constructors, or destructors and it has abstract method,property's signature but no implementation.

No comments:

Post a Comment