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}。