2D Arrays: Creation and Access

AP Computer Science A· difficulty 2/5

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

What is printed?

  • A

    6

    check_circle
  • B

    3

  • C

    5

  • D

    4

Explanation

m[1] is the second row {4, 5, 6}, and m[1][2] is the third element of that row, which is 6.

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

Related questions

AP Computer Science A · 2D Arrays: Creation and Access Practice Question | Acemy