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

JQ+: Constructors and access

 
Ranjan Chaudhuri
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
True or False:
You can only call public and protected constructors of the superclass in a subclass if the subclass is not in the same package because only those are inherited.
If the answer is "False," please provide an example to illustrate.
Thanks.
 
kanchan chaudhary
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I think, U can access the public & protected constructors in other package also. But the reason is not correct as the constructors R not inherited, they R accessible.
Thanks
kanchan
 
Bin Wang
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ranjan Chaudhuri:
True or False:
You can only call public and protected constructors of the superclass in a subclass if the subclass is not in the same package because only those are inherited.
If the answer is "False," please provide an example to illustrate.
Thanks.

Ranjan,
You must forget that constructors are not inherited, right?
Opps,
 
Ranjan Chaudhuri
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Kanchan and Bin.
I need to learn to read the COMPLETE #$%^& question!
Anyway, to confirm what you say with a quote from the JLS(8.2)
"Constructors, static initializers, and instance initializers are not members and therefore not inherited."
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic