What would be the result of compiling and running the following program?.
public class Main { int[] ia = new int[1]; boolean b;/*ww w . j a v a 2 s . c o m*/ int i; Object o; public static void main(String[] args) { Main instance = new Main(); instance.print(); } public void print() { System.out.println(ia[0] + " " + b + " " + i + " " + o); } }
Select the one correct answer.
(d)
The program will print "0 false 0 null" when run.
All the instance variables, including the array element, will be initialized to their default values.
When concatenated with a string, the values are converted to their string representation.
Notice that the null pointer is converted to the string "null", rather than throwing a NullPointerException.