Static Initialization Block

6. Program

//Find the O/P ? Compile Time Error or Compile Successfully ?

class F { static { i = 1; } static int i = 2; public static void main (String args[]) { System.out.println(i); } }

7. Program

//Find the O/P ? Compile Time Error or Compile Successfully ?

class F1 { public static void main (String args[]) { System.out.println(i); } static int i = 10 ; }

8. Program

//Find the O/P ? Compile Time Error or Compile Successfully ?

class G { static { System.out.println(i); } static int i ; public static void main (String args[]) { System.out.println("Done"); } }

9. Program

//Find the O/P ? Compile Time Error or Compile Successfully ?

class H { static int i ; static { i = j ; } static int j = 10 ; public static void main (String args[]) { System.out.println("Done"); } }

10. Program

//Find the O/P ? Compile Time Error or Compile Successfully ?

class I { static int i = test(); static { System.out.println("SIB1"); } static int test() { System.out.println("test"); return 10; } public static void main (String args[]) { System.out.println("Done"); System.out.println(i); } static { System.out.println("SIB2"); } }

Page....