Java - What is the output: local variable access?

Question

What is the output?


public class Main {
  public static void main(String[] args) {
    int sum;
    System.out.println(sum);
  }
}


Click to view the answer

System.out.println(sum); The local variable sum may not have been initialized

Note

The code will generate a compiler error because it tries to print the value of the local variable, sum, before it is assigned a value.