• 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

Constructor

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I instantiate the DataInputStream like this,

I know, all the constructors upto the hierarchy will be called. But when you instantiate the DataInputStream, what superclass constructor gets called? Will be default constrctor created by java or the superclass FilterInputStream's constructor?
If I create a subclass, I will always assume that the subclass will put super(); as the first line in its constrctor if I don't call superclass constructor explicitly or I will call the superclass constructor explicitly, There should be matching superclass constructor in either case.
In DataInputStream, there is no DataInputStream() constructor which takes no argument. So what is the calling hierarchy? Anyone make the concept clear for me?
Thanks.
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless you specify the constructor to be invoked (by your own call to super), the JVM will automatically invoke the default constructor of the parent class (the one that takes no arguments). In the case that you are extending a class that has no "no-args" constructor, you will be required to invoke a specific constructor in each of your constructors.
Corey
 
crispy bacon. crispy tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic