Consider the following code fragment: int[] list = new int[10]; for ( int i = 0;
ID: 3618797 • Letter: C
Question
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?
A) list.length must be replaced by 10
B) The loop body will execute 10 times, filling up the array withrandom numbers.
C) The loop body will execute 10 times, filling up the array withzeros.
D) The code has a runtime error indicating that the array is out ofbound.
27.
Given the following statement:
int[ ] list = new int[10];
Explanation / Answer
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?
A) list.length must be replaced by 10
B) The loop body will execute 10 times,filling up the array with random numbers.
C) The loop body will execute 10 times, filling up the array withzeros.
D) The code has a runtime error indicating that the array is out ofbound.
27.
Given the following statement:
int[ ] list = new int[10];
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.