| January 01, 2008 13:48:06 |
#20 |
| Mithun Challa |
Member Since: January 2008 Total Comments: 6 |
RE: What is the difference between Abstract class and Interface |
Ok this is one of the common interview questions. Let me put this in simple words
when you use Interface : There can be different classes which show different behaviour. Like consider a case I want to put all animals in a tree structure. I have top most defination as Animal then we have birds, reptiles, mammals etc.. Now all these have different features from each other yet they show some common features like they move they eat food ... so i will use Animal as interface and define those features in the class that implements it.
when you use abstract class: when i want to show a is-a type of realtion. now lets go further with the same example now I want to further classify my birds as those which can fly and those that cann't fly.. now this is specific to the birds in here i will go with abstract class.
|
| |