| 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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
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
|
 |
 |
|
|
subject: static block or initialisation block
|
|
|