Static Initialization Block

1. Program

//What will be the O/P ?

class A { static { System.out.println("SIB"); } public static void main (String args[]) { System.out.println("Main"); } }

2. Program

//What will be the O/P ?

class B { public static void main (String args[]) { System.out.println("Main"); } static { System.out.println("SIB"); } }

3. Program

//What will be the O/P ?

class D { static { System.out.println("SIB"); } public static void main (String args[]) { System.out.println("Main"); } static { System.out.println("SIB"); } }

4. Program

// What will be the O/P ?

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

5. Program

//What will be the O/P ?

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

Page....