This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes superclass' default construct Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "superclass Watch "superclass New topic
Author

superclass' default construct

Roger Zhao
Ranch Hand

Joined: Aug 05, 2003
Posts: 73
Hi, all:

The default constructor(no arguments) in Class B is needed to compile the constructor marked **. why?
thanks.
Added code tags - Barry
[ August 18, 2003: Message edited by: Barry Gaunt ]

"There is a will,there is a way!"<br />SCJP1.4
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Any subclass Constructor that does not have an explicate call to it's Super class Constructor gets an implicate call to the super classes default constructor. The code:

is exactly the same as


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Is class A extending Demo or B?
If it's B, then, as Carl has said, there is an implicit call to B's no argument constructor as the first statement in the A(int, int) constructor.
[ August 18, 2003: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
Shoot, thanks Barry, I quick scanned the question and missed the fact that A extended Demo and not B. I assumed it did just by the nature of the question.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: superclass' default construct