Hi,
Usually,
java program starts from main block, but if u use static blocks, it will first do the static blocks, and then enter into main block.
In you example, it will first assign a = 5, then prints the value of a.
Vanitha
Originally posted by kapil apshankar:
hi,
1.what is the practical use of such a block of code?
public class Test {
static {int a = 5; }
public static void main(String args[]) {
System.out.println(a);//illegal as a cannot be accessed out of the static block
}
}
2. I was checking up Sahir's mock Test applet. He has tested exhaustively on constructors and method signatures i.e what are valid constructors for this class etc. Is it required to be so extensive and perfect in constructors or does a passing glance through them suffice?
Regards,
Kapil