Originally posted by sridhar row:
... My doubt is how come the constructor in the dog class is being invoked when the new is done on the Animal class...
Define a no arg constructor in Animal class , it will run properly then
See its like , the derived class tries to call no argument constructor of base class if you don't call , explicitly any other constructor by using super.
If a constructor body does not begin with an explicit constructor invocation and the constructor being declared is not part of the primordial class Object, then the constructor body is implicitly assumed by the compiler to begin with a superclass constructor invocation "super();", an invocation of the constructor of its direct superclass that takes no arguments.