Because the second “numbers” reference variable is pointing to a new int array, while the initial int array got garbage collected. And since the new numbers array consists of 4 elements, the program assigns two values for the third and fourth elements, leaving the first and the second to the default assignment (i.e. zeros). Therefore, we will get 0 0 30 40.
0
0
30
40
B
B:
# javac Test32.java
# java Test32
0 0 30 40
Answer B:
Because the second “numbers” reference variable is pointing to a new int array, while the initial int array got garbage collected. And since the new numbers array consists of 4 elements, the program assigns two values for the third and fourth elements, leaving the first and the second to the default assignment (i.e. zeros). Therefore, we will get 0 0 30 40.
B is correct
B