Multiple choice technology programming languages

package staticinit; public class TestStaticInit { { System.out.print("I am in Init "); } TestStaticInit() { System.out.print("Constructor. "); } static { System.out.print("I am in Static. "); } static { System.out.print("I am in Static1. "); } public static void main(String[] args) { } }

  1. No output

  2. I am in Static. I am in Static1.

  3. Run time exception

  4. Compiler error

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

Static blocks execute when the class is loaded, even if no objects are created. Since main() is static, merely loading the class to execute main() triggers all static blocks in order. Instance initialization blocks and constructors only run when 'new' is used.