KnowledgeBoat Logo
|

Computer Applications

Given that int z[ ][ ] = {{2, 6, 5}, {8, 3, 9}}; What will be value of z[1][0] and z[0][2] ?

  1. 2 and 9
  2. 8 and 5
  3. 2 and 5
  4. 6 and 3

Java Arrays

9 Likes

Answer

8 and 5

Reason — Two-dimensional arrays are stored in a row-column matrix, where the first index indicates the row and the second indicates the column.

The element stored at z[1][0] refers to the element stored in second row and first column, which is 8.

The element stored at z[0][2] refers to the element stored in first row and third column, which is 5.

Answered By

2 Likes


Related Questions