File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: superclass' default construct
 
Similar Threads
confusion with primitives
Constructor question
Sylvan's Mock Question
Constructor
constructor signatures superclass