+ 2

Advantage of inheritence?

16th Dec 2016, 2:16 AM
Vannak Saing
Vannak Saing - avatar
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.
16th Dec 2016, 2:48 AM
Kirk Schafer
Kirk Schafer - avatar
+ 2
code re-use, and real-like modeling wich help to thought problems and solution in a more natural way.
16th Dec 2016, 2:20 AM
Nahuel
Nahuel - avatar
+ 2
Code reusebality. Java doesn't support multiple inheritance
17th Dec 2016, 4:22 PM
uday chafale
uday chafale - avatar
+ 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."
17th Dec 2016, 7:02 PM
Kirk Schafer
Kirk Schafer - avatar