Given the following code:

int[] intArr = {15, 30, 45, 60, 75};
intArr[2] = intArr[4];
intArr[4] = 90;

What are the values of each element in intArr after this code has executed?

A.

15, 60, 45, 90, 75

B.

15, 90, 45, 90, 75

C.

15, 30, 75, 60, 90

D.

15, 30, 90, 60, 90

E.

15, 4, 45, 60, 90

题解

这题要注意 Java 的数组索引是从 0 开始的。

第 2 进程式运行后,数组的内容为 {15, 30, 75, 60, 75}。

第 3 进程式运行后,数组的内容为 {15, 30, 75, 60, 90}。