Hi there.
I come across this question posted by Anil Paul in JavaDiscuss, I hope someone can help me out. Thanks.
Question: What is the output?
public class StaticTest
{
static
{
System.out.println("In static");
}
{
System.out.println("In non - static");
}
public static void main(
String args[ ])
{
StaticTest st1;
System.out.println(" 1 ");
st1 = new StaticTest();
System.out.println(" 2 ");
StaticTest st2 = new StaticTest();
}
}
Answer:
In static
1
In non - static
2
In non - static