2D Arrays: Creation and Access

AP Computer Science A· difficulty 3/5

String[][] grid = new String[2][2];
grid[0][0] = "A";
grid[0][1] = "B";
grid[1][0] = "C";
System.out.println(grid[1][1]);

What is printed?

  • A

    null

    check_circle
  • B

    ""

  • C

    C

  • D

    Compile-time error

Explanation

Default value for object references in an array is null. grid[1][1] was never assigned.

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

Related questions

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