Instance Initialization block (IIB)

5. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class E { { System.out.println("E-IIB1"); } E(int i) { System.out.println("E(int)"); } public static void main(String[] args) { E e1 = new E(90); System.out.println("------"); E e2 = new E(30); System.out.println("------"); } { System.out.println("E-IIB2"); } }

6. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class E1 { { System.out.println("E1-IIB1"); } public static void main(String[] args) { E1 e1 = new E1(); System.out.println("------"); E1 e2 = new E1(); System.out.println("------"); } { System.out.println("E1-IIB2"); } }

7. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class E2 { { System.out.println("E2-IIB1"); } E2(int i) { System.out.println("E2(int)"); } public static void main(String[] args) { E2 e1 = new E2(90); System.out.println("------"); } { System.out.println("E2-IIB2"); } { System.out.println("E2-IIB3"); } }

8. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class F { F(boolean flag) { } F(int i, int j) { System.out.println(i); System.out.println("F(int)"); } public static void main(String[] args) { F f1 = new F(true); System.out.println("------"); F f2 = new F(100, 200); System.out.println("------"); } { System.out.println("F-IIB"); } }

Page....