1.

What will be the output of the below code?

Answer»

class SCALER{ static INT i; static { System.out.println(“a”); i = 100; }}public class StaticBlock{ static { System.out.println(“b”); } public static void MAIN(String[] ARGS) { System.out.println(“c”); System.out.println(Scaler.i); }}

Output:

bca100

Reason:
FIRSTLY the static block inside the main-method calling class will be implemented. Hence ‘b’ will be printed first. Then the main method is called, and now the sequence is kept as expected.



Discussion

No Comment Found