Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
when the above program is executed first SuperClass Constructor and then ChildClass constructor is (executed)displayed. What is the use of having the super keyword in the child class constructor when infact the super class constructor is executed when the object for the child class is created since the child class extends to the superclass.
There's no real use to call super(), because it's called implicitly whether you write it or not. Some people prefer to make it explicit, but it's unnecessary.
However, it *is* important to call super(...) at the start of the constructor if you want to invoke a superclass constructor that has parameters. Here's an example:
So unless we have to call the constructor which has got parameters it's ok not to use super keyword as this is implicitly called.. correct me if am wrong...
Let creation of an object of subclass invokes non-parameterized Or parameterized constructor of subclass, implicitly It invokes non-parameterized constructor of superclass by default. Sometime you may need to invoke a particular type of superclass's constructor rather than non-parameteried as given in Stephan's example then you can use super keyword.
That super keyword statement should always be first statement in constructor of subclass.