tags:

views:

80

answers:

1

It's actually from SCJP 6 StudyGuide Exam310-065(MGH,2008) alt text alt text alt text alt text

The call to super() in Kinder class constructor seems to be redundant because of:

  • quote from the book: alt text i.e. that there is no need to type super() explicitly, as this can be done by compiler
  • the compiler accepts very well version without call to super()

The question is, if authors made some mistake in this question or am I missing something (more likely)

+1  A: 

Sorry, I may be missing something (most likely), but it sounds like it's stated in the text:

a. The line cannot be left blank, as the parentheses are already in place.

That is, a constructor can be empty.. except that empty parentheses would be a syntax error (so it wouldn't compile).

b. Further, since the superclass constructor called is the no-argument version, this constructor must be created.

I think you may just have to re-read the text one more time and it should all click. Or I am really off on the whole thing.. in that case I apologize, it's kind of late over here. ;-)

pithyless
a) constructor with empty body is not a syntax error. b) I have no objection that no-arg constructor should be created, my point was that super()-call is redundant
kilonet
@kilonet: you are correct in both points, but they are not relevant to the question. Since the template already has the parenthesis in there without an argument, you need to put *something* there to make it valid Java code. That's the only reason for the no-args `super()` call there. It's a kind of trick question, in my opinion.
Joachim Sauer