Page 1294 - AP Computer Science A, 7th edition
P. 1294
6. (A) A matrix is stored as an array of arrays, that is, each row is an array. Therefore it is correct to call a method with an array parameter for each row, as is done in Segment I. Segment II fails because mat is not an array of columns. The segment would cause an error, since mat[col] refers to a row, not a column. (If the number of rows were less than the number of columns, the method would throw an ArrayIndexOutOfBoundsException. If t he num ber of row s were greater than the number of columns, the method would correctly assign the value 100 to the first n rows, where n is the number of columns. The rest of the rows would retain the values before execution of the method.) Segment III fails because you cannot assign new elements in a for-each loop. The matrix remains unchanged.