aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Superclass Constructor 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 "Superclass Constructor " Watch "Superclass Constructor " New topic
Author

Superclass Constructor

karl czukoski
Greenhorn

Joined: Dec 30, 2010
Posts: 22
Given:


prints: b h hn x

Can someone explain why the first constructor Building() of the superclass Building is called instead of the second constructor Building(String name) ?
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
After I fixed the compiler error, it does not print b h hn x . It prints:
b h
bn x
I think you are running old code.
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

@ karl
welcome to the javaranch family

please QuoteYourSources

SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
karl czukoski
Greenhorn

Joined: Dec 30, 2010
Posts: 22
Thanks Prasad

So correct me if wrong but I think the first constructor Building() of the superclass Building is used b/c the compiler looks for the no-arg constructor (basing this logic off of question 2 pg. 172 explanation).
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 446
    
    1

QuoteYourSources means please provide the source from where you got this question
 
 
subject: Superclass Constructor