0%
0 / 15 answered

Nested Iteration Practice Test

15 Questions
Question
1 / 15
Q1

A class stores daily step counts in a 2D array (weeks by days). Given the program below,


int[][] steps = {

  {1000, 2000, 3000},

  {4000, 5000, 6000}

};

int max = steps<u>0</u><u>0</u>;

for (int r = 0; r < steps.length; r++) {

  for (int c = 0; c < steps<u>r</u>.length; c++) {

    if (steps<u>r</u><u>c</u> > max) {

      max = steps<u>r</u><u>c</u>;

    }

  }

}

System.out.println(max);

What is the output of the following nested loop?

Question Navigator