2D Arrays: Creation and Access

AP Computer Science A· difficulty 4/5

int[][] m = {{1, 2, 3}, {4, 5, 6}};
int[] row = m[0];
row[1] = 99;
System.out.println(m[0][1]);

What is printed?

  • A

    99

    check_circle
  • B

    2

  • C

    5

  • D

    0

Explanation

row is a reference to m[0]. Modifying row[1] modifies m[0][1], so it prints 99.

Want 10 more like this — adaptive to your weak spots?

Related questions