• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JQ+: Constructors and access

 
Ranjan Chaudhuri
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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."
 
reply
    Bookmark Topic Watch Topic
  • New Topic