In this program, we will create multiple Instance Initializer Block in a class. The IIB (Instance Initializer Block) is called when an object is getting created.
Program/Source Code:
The source code to create multiple Instance Initializer Block is given below. The given program is compiled and executed successfully.
// Java program to create multiple Instance
// Initializer Block
class Sample {
{
System.out.println("IIB1 called");
}
{
System.out.println("IIB2 called");
}
Sample() {
System.out.println("Constuctor called");
}
{
System.out.println("IIB3 called");
}
}
public class Main {
public static void main(String[] args) {
Sample S = new Sample();
}
}
Output:
IIB1 called
IIB2 called
IIB3 called
Constructor called
In this program, we will create multiple Instance Initializer Block in a class. The IIB (Instance Initializer Block) is called when an object is getting created.
Program/Source Code:
The source code to create multiple Instance Initializer Block is given below. The given program is compiled and executed successfully.
Output: