Have you read through the What is inheritance? trail? Implementation is exactly as you would expect. If you implements an interface you put into use it's protocol of behaviour. Read the What is an interface? trail for more information on what an interface is. [ October 06, 2004: Message edited by: Nigel Browne ]
I am providing the following explanation you can analyse this and I am sure your concepts will be very clear after going through this.
Inheritance offers the following benefits:
Subclasses provide specialized behaviors from the basis of common elements provided by the superclass. Through the use of inheritance, programmers can reuse the code in the superclass many times. That means, you can use the method definition in the parent class in your subclass.
Programmers can implement superclasses called abstract classes that define "generic" behaviors. The abstract superclass provides method declarations. Other programmers fill in the details with specialized subclasses.
So in brief when you are using inheritence you are using the already existing code by extending that class. However in case of interfaces most of the code is to be written by the programmer and the interface provides as a layout which has to be followed.
Hope it helps you. [ October 06, 2004: Message edited by: prashant bhogvan ]
- Favor object composition (delegation) over class inheritance
This is important to remember. Yes, Inheritance is a good feature, and has it's advantages but don't forget the following disadvantages: * the subclass becomes dependent on the parent class implementatio, which makes it harder to reuse the subclass. * You can only add classes at compile time, and not dynamicly at runtime.
In general one should favor composition over inheritance, as it promotes smaller and more focused classes.
With that beeing said, inheritance is still important