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 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 of the types listed below can be the type of a function output parameter?

a. int * b. double * c. char * d. all of the above e. none of the above

Computer Science & Information Technology

Using an application's _____ settings, you can select how you want to handle updates.

A. Preferences B. Download C. Update D. Upgrade

Computer Science & Information Technology

Pico projectors typically create a display up to about 10 feet wide in order to easily share information stored on the device without everyone having to crowd around a tiny screen.

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

Computer Science & Information Technology

All legal documents use a 2" top margin.

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

Computer Science & Information Technology