This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread 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 Android Security Essentials Live Lessons this week in the Android 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>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SubClass Constructor Question
 
Similar Threads
Method Overriding...
instance variables & constructors
Invoking Private Constructor
Doubt in Constructors
JAVA Package Query