Question 1
Back to Exercise
What is the output of the following Java program?
public class Main {
public static void main(String[] args) {
int[] a = new int[2];
double[] d = new double[2];
boolean[] b = new boolean[2];
String[] s = new String[2];
char[] c = new char[2];
System.out.println(a[0] + " " + d[1] + " " + b[0] + " " + s[1] + " " + (int) c[0]);
}
}
- A 0 0.0 false null 0 Correct
- B 0 0 false "" 0
- C null null null null null
- D Compilation error
Correct Answer: Option A
Array elements always get default values, even in local arrays.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!