The loop body will execute 10 times


Consider the following code fragment:

int[] list = new int[10];
for (int i = 0; i <= list.length; i++) {
list[i] = (int)(Math.random() * 10);
}

Which of the following statements is true?

-The loop body will execute 10 times, filling up the array with random numbers.
-The loop body will execute 10 times, filling up the array with zeros.
-list.length must be replaced by 10
-The code has a runtime error indicating that the array is out of bound.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: The loop body will execute 10 times
Reference No:- TGS0129155

Expected delivery within 24 Hours