The following loop displays _______________.

for (int i = 1; i <= 10; i++) {
System.out.print(i + " ");
i++;
}

a. 1 2 3 4 5 6 7 8 9
b. 1 2 3 4 5 6 7 8 9 10
c. 1 2 3 4 5
d. 1 3 5 7 9
e. 2 4 6 8 10


d In this for loop, i is initialized to 1 . i++ adds 1 to i at the end of the iteration. In the action-after-each-iteration, i is again incremented by 1 . So, i is in effect incremented twice. So, i is 1, then 3, 5, 7, and 9.
The correct answer is D.

Computer Science & Information Technology

You might also like to view...

Which of the following is not an ANOVA calculation type?

A) Two wing B) Two-factor without replication C) Single-factor D) Two-factor with replication

Computer Science & Information Technology

Referring to the figure above, Item 1 refers to the Tag Properties panel option which shows properties that have had attributes specified at the top of the list.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

What attribute must theformelement contain to enable form submission? What attribute must all elements within the form contain? How are the values of these attributes used in form submission?

What will be an ideal response?

Computer Science & Information Technology

The following provides guidelines for documenting research in literature, languages, linguistics, and composition studies:

Computer Science & Information Technology