How many times will the following code print "Welcome to Java"?
int count = 0;
while (count++ < 10) {
System.out.println("Welcome to Java");
}
a. 8
b. 9
c. 10
d. 11
e. 0
c The count is initialized to 0 before the loop. (count++ < 10) increments count by 1 and uses the old count value to check if count < 10 . So, the loop is executed 10 times for count from 0 to 9 . The correct answer is C.
Computer Science & Information Technology
You might also like to view...
Views can be changed by clicking the View tab or the Views button on the ________
Fill in the blank(s) with correct word
Computer Science & Information Technology
When you are highlighting text, if no text is selected, the pointer changes to the Highlighter pointer, an I-beam pointer with a ____ on it, when you position it on top of text in the document.
A. paintbrush B. marker C. pencil D. pen
Computer Science & Information Technology