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...

We cannot always return by reference because:

A. we might be returning a local object, which would be destroyed at the end of function execution B. we might not want changes in the object of the called function to be reflected back to the calling function C. the address of the returned object might not be known D. the name of the object is not always permanent

Computer Science & Information Technology

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

1. An uncaught exception in C++ is ignored. 2. If an exception is thrown in a function, say, f(), but not handled there, the exception is propagated to the function that called f(). 3. A circumstance in C++ where an exception is thrown must be an error. 4. When an event occurs that cannot be managed locally, an exception may be thrown. Throwing the exception object transfers control and information gleaned locally to some calling program unit that manages the event, or the program terminates. 5. In C++, an exception object can be a user-defined type or any type that is built-into C++ language.

Computer Science & Information Technology

Which of the following provides access to one or more applications through a single centralized interface?

A. Remote access portal B. Virtual private network C. Network access control system D. DMZ

Computer Science & Information Technology

Fragment-free switches are also known as ____ switches.

A. fast forwarding B. error sensing C. cut-through D. modified cut-through

Computer Science & Information Technology