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) 2020 – Preliminary (DU) exam, question 26 of 47.

More from this paper