Java calls the constructors of every superclass in its inheritance tree. (In this example that would be the constructors of both Animal and Object.)
My question is ... why? As a programmer, my intent when I create a new Horse is to create one object not three? Doesnt this cause a performance penalty if the inheritance tree is large? I'm curious about the reasoning behind this approach? Is it so that superclass methods are available?
When it comes to Inheritance, without having a parent class object how could you ever think of your child class object possessing the characteristics of parent class? Wouldn't it make the whole point of Inheritance go waste?
Though you may use it or not, but it IS assumed that the super class object(s) should be available for the subclass object(s) in the inheritance hierarchy.
Does that quench your thirst Keith?
Of course, a good question . Way to think and understand the concepts!
Just to clarify: when you instanciate a Horse, only *one* object is created - a Horse object.
But consider this: the Horse class inherits every part of the Animal class, but the Horse constructor doesn't know how to initialize those parts. Only the Animal constructor knows how to do that. So the Horse constructor calls the Animal constructor to initialize the Animal parts of the Horse object.
Does that help?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus