COP2250-St. Petersburg College-JAVA PROGRAMMING I MODE-Quiz Submissions-Chapter 5 Quiz
Question
UNIVERSITY | CODE | WORDS COUNT | REFERENCE |
St. Petersburg College | COP2250 | 50 | APA |
QUESTIONS:-
1- int z = 2, sum = 0;while (z < 9) { z++; sum = sum + z;}System.out.print(sum);What is the output?
2- int n;for(n = 8; n < 30; n += 5) { //}System.out.print(n);
What is printed when the loop above has finished?
33 |
Nothing. Compilation fails. |
31 |
32 |
3- int x=1;while(x <= 5) { x++; System.out.print(x);}What is output by the code above?
4- In which instance can a loop not require braces?
when the number of iterations cannot be predetermined |
when only one statement is to be repeated |
when the number of iterations can be predetermined |
when the loop is a do-while loop |
in progress
0
Java
1 Answer
475 views
0
Answer ( 1 )
1. Answer: 32
2. Nothing. Compilation fails.
3. Answer: 6
4. when the number of iterations can be predetermined