Analyze the following code:
class Test {
public static void main(String[] args) {
int[] x = {1, 2, 3, 4};
int[] y = x;
x = new int[2];
for (int i = 0; i < y.length; i++) {
System.out.print(y[i] + " ");
}
}
}
- A. The program displays 1 2 3 4
- B. The program displays 0 0
- C. The program displays 0 0 3 4
- D. The program displays 0 0 0 0
The answer for the following code is A. But why the answer is not B ?



xandyare references.