Multiple choice technology programming languages

class C{ public static void main(String a[]) { int i1=9; int i2; if(i1>3) { i2=8; } System.out.println(i2); }}What is the result of attempting to compile and run the program?

  1. compile time error

  2. Runtim error

  3. prints 8

  4. prints 0

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

The variable i2 is only assigned inside the if block, but it's declared outside. Java requires local variables to be definitely assigned before use. If i1 were less than or equal to 3, i2 would be uninitialized when println is called. This is a compile-time error.