Question 10 What does the following code do? Assume \"names\" is an array of Str
ID: 3606813 • Letter: Q
Question
Question 10
What does the following code do? Assume "names" is an array of String values.
for (int index = names.length-1; index >= 0; index--)
System.out.println(names[index]);
A.
It will generate an error because index cannot be zero.
B.
It prints the values stored in names backwards, except for the last value in the array.
C.
It prints the values stored in names backwards.
D.
It does not print out anything because the index should be increased not decreased.
A.
It will generate an error because index cannot be zero.
B.
It prints the values stored in names backwards, except for the last value in the array.
C.
It prints the values stored in names backwards.
D.
It does not print out anything because the index should be increased not decreased.
Explanation / Answer
Answer: Option C
It prints the values stored in names backwards.
for (int index = names.length-1; index >= 0; index--)
System.out.println(names[index]);
It prints the values stored in names backwards.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.