Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How does Initilization Block(Static and Instance) work?

 
Vishal Kashyap
Ranch Hand
Posts: 73
BSD C++ Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
I am little bit confused about the execution of Initialization blocks; mainly about Instance Init Blocks. I know they executes whenever instance of class has been created after super() call, but when we are creating instance of sub sub sub class then what will be the actual process for its execution? Please check out following code,



What will the the result of above code after execution? Why it will be? How it will be?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wouldn't it be easier to run it and find out. Then you can post what part of the output surprises you and we can discuss that.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, we ask you to state where mock exam questions come from. This one has been discussed here and here.
 
Vishal Kashyap
Ranch Hand
Posts: 73
BSD C++ Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Boyarsky Ma'am,
I got my answer in your second link and too much satisfied with that.
thanks once again.
 
Rob Spoor
Sheriff
Pie
Posts: 20550
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishal Kashyap wrote:Thanks Boyarsky Sir,

That would be "Boyarsky Ma'am".
 
Vishal Kashyap
Ranch Hand
Posts: 73
BSD C++ Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh! sorry for that.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic