Hi All,
Here is one more teaser if you have time to answer
What will be the result of attempting to compile and run the following class?
public class InitTest
{
static
String s1 = sM1("a");
{
s1 = sM1("b");
}
static
{
s1 = sM1("c");
}
public static void main(String args[ ] )
{
InitTest it = new InitTest( );
}
private static String sM1(String s)
{
System.out.println(s) ; return s;
}
}
a)The program will fail to compile
b)The program will compile without error and prints a,c,b in that order when run.
c)The program will compile without error and prints a,b,c in that order when run.
d)The program will compile without error and prints c,a,b in that order when run.
e)The program will compile without error and prints b,c,a in that order when run.