This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
That's true, but not only the default constructor in the subclass does this. Even if you have a non-default constructor in your sub-class, it will still call the default constructor of the supper class, unless you specify the correct signature of the non-default constructor of the super-class (if there are any) in the constructor of the subclass. take this example:
HTH Edited by Corey McGlone: Broke up the long comment into multiple lines for better display. [ July 11, 2002: Message edited by: Corey McGlone ]
Joined: Jun 19, 2002
guys sorry about the messup of putting a long text inside the brackets. didn't realize the side-effect!
Huh? That statement says that a compiler error occurs if the superclass doesn't have an accessible no-args constructor. This would only be an error is the default constructor tried to invoke the no-args constructor. Therefore, this statement is proving the fact that a default constructor invokes the no-args constructor of the superclass, not the other way around. Try this:
Joined: Mar 22, 2002
Amir yaar what have you done?
Well, I never liked splitting hairs, but IMHO the question was if the superclass constructor will be invoked, not if the invocation was actually successful.