Which two statements are true for a two-dimensional array of primitive data type?



A. It cannot contain elements of different types.
B. The length of each dimension must be the same.
C. At the declaration time, the number of elements of the array in each dimension must be specified.
D. All methods of the class object may be invoked on the two-dimensional array.

題解

選項A,基本資料型態的二維陣列不能包含其他不同型態的元素,這是正確的。

選項B,Java允許多維陣列每個維度擁有不同的長度。

選項C,定義陣列型態的時候,可以先不用把每個維度的元素數量給決定好,實體化陣列物件的時候再決定即可。

選項D,所有在Object類別裡的方法都可以在陣列中調用,因為陣列也是物件,同樣繼承自Object類別。