This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes SubClass Constructor Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "SubClass Constructor Question" Watch "SubClass Constructor Question" New topic
Author

SubClass Constructor Question

Ehsan Rahman
Ranch Hand

Joined: Feb 16, 2009
Posts: 59

Hello everyone,

Suppose:



and ...



Why is it that the "new FundamentalsTest();" statement in line 9 is not valid but the constructor chaining call by SubFundamentals to the FundamentalsTest() constructor is valid?

Many Thanks,
Ehsan


SCJP 1.5, SCJD 1.6
Tom Johnson
Ranch Hand

Joined: May 11, 2005
Posts: 142
The class named FundamentalsTest is not in the same package as SubFundamentals. The constructor of FundamentalsTest is protected, hence you cannot call it directly from a different package.


<a href="http://faq.javaranch.com/java/UseCodeTags" target="_blank" rel="nofollow">Use Code Tags!!</a>
 
jQuery in Action, 2nd edition
 
subject: SubClass Constructor Question