What is the output of the following code?

```

int x = 0;
while (x < 4) {
x = x + 1;
}
System.out.println("x is " + x);
```

a. x is 0
b. x is 1
c. x is 2
d. x is 3
e. x is 4

e. x is 4
x is 0 before the loop. The loop is executed 4 times for x from 0 to 3. When x is 4 the loop exits. So, the correct answer is E.

Computer Science & Information Technology

You might also like to view...

Which computer platform is well known for the strength of its graphic and audio capabilities?

A) Windows B) Linux C) IBM D) Apple

Computer Science & Information Technology

Consisting of an array of 2” squares representing all possible combinations of values of n binary variables, the _________ is a convenient way of representing a Boolean function of a small number (up to four) of variables.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology