Static Block
Static block is used to initialize or change the java default static variables. When class is loaded this block gets executed and all static variables initialized.
In a class there may be multiple static block, they will be loaded in the sequence in which they are declared.
Program:
Output:
There are three static blocks in this program and they loaded before executing main() function in sequence in which they are declared.
need an explanation for this answer? contact us directly to get an explanation for this answer