This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes static block or initialisation block Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "static block or initialisation block" Watch "static block or initialisation block" New topic
Author

static block or initialisation block

venkatesh badrinathan
Ranch Hand

Joined: Aug 03, 2008
Posts: 77
static block or initialisation block.. which of these first executes in a program..???


SCJP1.5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

static intializer block executes when a class is intialized. instance intializer block is executed when a class is instantiated i.e. an object of a class is created. As you must know a class is loaded when the JVM starts. so static intializer block is executed when the JVM starts. But instance intializers execute when an object of a class is created. If no object of a class is created then the instance initializer block will never be executed.


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
venkatesh badrinathan
Ranch Hand

Joined: Aug 03, 2008
Posts: 77
thank you AnkitJi Garg.. you are really great
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: static block or initialisation block