0%
0 / 25 answered

Practice Test 5

25 Questions
Question
1 / 25
Q1

A class analyzes a 2D array of survey ratings and wants the average per row. Consider the following Java code.


int[][] ratings = {

  {4, 5, 3},

  {2, 1, 3}

};

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

  int rowSum = 0;

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

    rowSum += ratings<u>r</u><u>c</u>;

  }

  System.out.print(rowSum + " ");

}

What is the output of the following nested loop?

Question Navigator