Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Confused about this output-Constructor doubt  RSS feed

 
Amit Batra
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

how come after the implicit call to super() in X's constructor it busts out of the constructor to create Y() first before finishing up its own work?
 
bing marquez
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check this out.
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Initialization:

In Java , when an object is created, initialization is done in this order:
  • Set fields to default initial values (0, false, null)
  • Call the constructor for the object (but don't execute the body of the constructor yet)
  • Invoke the constructor of the superclass
  • Initialize fields using initializers and initialization blocks
  • Execute the body of the constructor

  •  
    Amit Batra
    Ranch Hand
    Posts: 361
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks guys.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!