SCJP-- 考试问题
它实际上来自SCJP 6 StudyGuide Exam310-065(MGH,2008) 替代文本 http://www.freeimagehosting.net/uploads/1f37466409.png 替代文本 http://www.freeimagehosting.net/uploads/03aaff252a.png 替代文本 http://www.freeimagehosting.net/uploads/b56385a448.png 替代文本 http://www.freeimagehosting.net/uploads/83761fff86.png
在 Kinder 类构造函数中调用 super() 似乎是多余的,因为:
- 书中引用: 替代文本 http://www.freeimagehosting.net/uploads/8984096dc6.png 即不需要显式键入 super(),因为这可以由编译器完成,
- 编译器接受非常好的版本,而无需调用 super()
问题是,如果作者在这方面犯了一些错误问题还是我错过了什么(更有可能)
It's actually from SCJP 6 StudyGuide Exam310-065(MGH,2008)
alt text http://www.freeimagehosting.net/uploads/1f37466409.png
alt text http://www.freeimagehosting.net/uploads/03aaff252a.png
alt text http://www.freeimagehosting.net/uploads/b56385a448.png
alt text http://www.freeimagehosting.net/uploads/83761fff86.png
The call to super() in Kinder class constructor seems to be redundant because of:
- quote from the book:
alt text http://www.freeimagehosting.net/uploads/8984096dc6.png
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉,我可能遗漏了一些东西(最有可能),但听起来就像文本中所述:
a。该行不能留空,因为括号已经就位。
也就是说,构造函数可以为空......除了空括号将是语法错误(因此它无法编译)。
b.此外,由于调用的超类构造函数是无参数版本,因此必须创建此构造函数。
我想你可能只需要再重新阅读一遍文本,就应该全部明白了。或者我真的对整个事情不感兴趣……在这种情况下,我很抱歉,这里有点晚了。 ;-)
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. ;-)