Question: Consider the following code fragment: int [ ] list; list = new int[10]; for (int i = 0; i

Consider the following code fragment:

int [ ] list;

list = new int[10];

for (int i = 0; i <= 10; i = i + 1)

{

list[i] = 0;

}

Which of the following statements is true?

The loop body will execute 9 times.
The program has a syntax error because the control variable, i, in the for loop is not defined in the body of the loop.
The loop body will execute 10 times, filling up the array with zeros.
The code has a runtime error indicating that the array is out of bound.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!