Multiple choice

What will be output of the following program?

class A {
 static{ 
  System.out.println("JAVA"); 
  System.exit(0); 
  }
}

  1. Compile time error

  2. Run time error

  3. Exception error

  4. JAVA

  5. 0

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

Correct! Because of JVM always execute instruction on the basis of priority so static block has higher priority than main method hence It will execute static block then after it will go to main method (which is essential for all the java programs to run) but here programmer written intelligently his program to get output.