How many times will the following code print "Welcome to Java"?
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.
You might also like to view...
Knowledge of enterprise computing is beneficial in a business environment
Indicate whether the statement is true or false
Use Ctrl + an arrow key to ________ a picture, or move it in small increments
Fill in the blank(s) with correct word
SQL stands for sequential query language.
Answer the following statement true (T) or false (F)
What is the loopback address and what is its purpose?
What will be an ideal response?