Traversing 2D Arrays

AP Computer Science A· difficulty 2/5

int[][] m = {{2, 3}, {4, 5}};
int product = 1;
for (int[] row : m) {
    for (int x : row) {
        product *= x;
    }
}
System.out.println(product);

What is printed?

  • A

    120

    check_circle
  • B

    60

  • C

    100

  • D

    14

Explanation

2 * 3 * 4 * 5 = 120.

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

Related questions