Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SubClass Constructor Question

 
Ehsan Rahman
Ranch Hand
Posts: 59
Chrome Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Tom Johnson
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic