File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes constructor problem? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "constructor problem?" Watch "constructor problem?" New topic

constructor problem?

Vishy Karl
Ranch Hand

Joined: Sep 08, 2003
Posts: 116
Hi All ,
Why does the foll. code compile??

I was expecting a compile time error as teh Class B does not contain the no-arg. constructor . Then how is the call to super(); in Class C resolved ???
Thanks in advance,
Best wishes,

"The man who can drive himself further once the effort gets painful is the man who will win." <br />Roger Bannister
Lakshmi Saradha
Ranch Hand

Joined: Oct 21, 2003
Posts: 170
Hi Vishy,
This is a tricky question.The line
public boolean B(String msg)
is a method and not a constructor since there is a boolean return type.
Sice there is no constructor,, a default nor arg constructor is provided adn hence this code gives no compiler error.

Thanks,<br />Lakshmi.
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1845

class B doesn't define any constructors, it will call default no-argument constructor....

Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Vishy Karl
Ranch Hand

Joined: Sep 08, 2003
Posts: 116
OOps , Sorry for the silly mistake
Thanks for your replies
jQuery in Action, 2nd edition
subject: constructor problem?