This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes confusion in output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "confusion in output" Watch "confusion in output" New topic
Author

confusion in output

sharma sachin
Greenhorn

Joined: Nov 13, 2009
Posts: 24

the output of the above program should be simply hello why it is printing sum=10 first and then hello according to this output the block should be of static but i have not written static even then it is printing sum=10 first and then hello.
can you please explain me the output, the block in which sum is printing which kind of block it is??
and what is the utility of this block, i am sure it is not a static block am i right??
Siva Masilamani
Ranch Hand

Joined: Sep 19, 2008
Posts: 385
All the instance initializer block will be executed in the declared order after every call to super constructor (super()) and then code inside the constructor will run and hence the above ouput.


SCJP 6,SCWCD 5,SCBCD 5

Failure is not an option.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confusion in output
 
Similar Threads
SCJP Brainteaser (4)
Doubt in static...
doubt
Confusion in "System.out.print()"
Without writing a main(),Can you execute a program?