Java - What is the output: local variable access?


What is the output?

public class Main {
  public static void main(String[] args) {
    int sum;

Click to view the answer

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


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.