Java program to implement static block with instance initializer block
belongs to collection: Java Instance Initializer Block Programs
All Answers
total answers (1)
belongs to collection: Java Instance Initializer Block Programs
total answers (1)
Program/Source Code:
The source code to implement static block with Instance Initializer Block is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created two classes Sample and Main. The Sample class contains a Static Block, IIB (Instance Initializer Block), and a constructor.
The Main class contains a method main(). The main() method is the entry point for the program, here we created an object of the Sample class called static block, IIB, and constructor of the class.