Advertuse

Search This Blog

Your Ad Here

Wednesday, 7 January 2009

Interface V/s abstract Class

In object oriented programming, interface and abstract class are use to represent common structure and behavior. but they have fundamental difference. which help to decide when you have to use interface and when you have to use abstract class.






Interface abstract Class
It is a composition of general behavior (not a structure).It is a composition of general behavior and structure as well.

interface has no implementation at all in its body. it only has the signature or in other words, just the definition of the methods without the body.
abstract class may have implementation in its body. and it can be override if it has override modifier
Multiple interface can be inherited in derived class
Multiple abstract class can not be inherited in derived class

Interfaces are used to define the peripheral abilities of a class.
An abstract class defines the core identity of a class.

No comments: