How many times will the following code print "Welcome to Java"?

```
int count = 0;
do {
System.out.println("Welcome to Java");
} while (count++ < 10);
```
a. 8
b. 9
c. 10
d. 11
e. 0


d. 11

The count is initialized to 0 before the loop. The loop is executed for the first time when count is 0. (count++ < 10) increments count by 1 and uses the old count value to check if count < 10. So, the loop is executed 11 times for count from 0 to 10. Note that when count is 10, the loop body is executed before the loop is exited. The correct answer is D.


Computer Science & Information Technology

You might also like to view...

Shorter, simpler handlers are easier to debug and maintain.

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

Computer Science & Information Technology

What is the purpose of the kernel?

What will be an ideal response?

Computer Science & Information Technology

________ images enables you to format them together as one unit

Fill in the blank(s) with correct word

Computer Science & Information Technology

In an outline each topic is either an outline level or identified as a body text

Indicate whether the statement is true or false

Computer Science & Information Technology