So I am a student and in the process of learning Java. There is one concept that I am having a difficult time grasping and am hoping that someone could shed some light on t
This is correct, even though the reference is of type Animal
, all method calls will resolve to the definition in Lizard
if present, otherwise the version in the next immediate parent will be called and so on.
a
is just a reference and the actual object is of type Lizard
. So, the constructors in Lizard
class will be called. They in turn can call the constructors in super classes using super()
.