aspose file tools*
The moose likes Beginning Java and the fly likes How does Initilization Block(Static and Instance) work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How does Initilization Block(Static and Instance) work?" Watch "How does Initilization Block(Static and Instance) work?" New topic
Author

How does Initilization Block(Static and Instance) work?

Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

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?


MCSA 2003 | Preparing For OCPJP/SCJP6
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30929
    
158

Also, we ask you to state where mock exam questions come from. This one has been discussed here and here.
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Thanks Boyarsky Ma'am,
I got my answer in your second link and too much satisfied with that.
thanks once again.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19760
    
  20

Vishal Kashyap wrote:Thanks Boyarsky Sir,

That would be "Boyarsky Ma'am".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Vishal Kashyap
Ranch Hand

Joined: Aug 07, 2010
Posts: 73

Oh! sorry for that.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does Initilization Block(Static and Instance) work?