+ 2
Advantage of inheritence?
4 Respostas
+ 3
Money, genes, stray animals, parents, ah-there it is...
Family traits.
You 'inherit' previously expressed attributes/behaviors but your copy of the traits can add--or subtract--features as they suit your code's generation...without having to recreate the entire code stream / bloodline...and you can also pass on your 'code' to the next generation.
+ 2
code re-use, and real-like modeling wich help to thought problems and solution in a more natural way.
+ 2
Code reusebality. Java doesn't support multiple inheritance
+ 2
To support @Uday's answer, here's a Java reference discussing how a MountainBike works within a single line of inheritance through Bike and Object:
http://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
An advantage that may be gleaned from this appears to be control over type checking (depending on whether you use implicit or explicit typecasting).
An explicit advantage in the article (as @Uday writes) is: "...reuse the fields and methods of the existing class without having to write (and debug!) them yourself."