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...
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
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.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
vijay arora
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.
There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |