What is the output of this Java program? class Test{ int i=1; } public class main{ public static void main(String args[]){ Test t…

What is the output of this Java program?

class Test{
    int i=1;
}
public class main{
  public static void main(String args[]){
    Test t;
    System.out.println(t.i);
  }
}
  1. a) The program will cause a runtime exception because the variable 'i' was not initialized
  2. b) The program will cause a compile error because the object 't' was not initialized
  3. c) 0
  4. d) A garbage value

From the Combined Bank Assistant Programmer (CSE) February 2024 – Written (BIBM) exam, question 25 of 41.

More from this paper