Java Programming

Computing

Quiz 5 :

Control Structures II: Repetition

Quiz 5 :

Control Structures II: Repetition

Question Type
search
arrow
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.
Free
True False
Answer:

Answer:

True

Tags
Choose question tag
close menu
arrow
A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met.
Free
True False
Answer:

Answer:

True

Tags
Choose question tag
close menu
arrow
The following for loop executes 21 times. (Assume all variables are properly declared.) for (i = 1; i <= 20; i = i + 1) System.out.println(i);
Free
True False
Answer:

Answer:

False

Tags
Choose question tag
close menu
arrow
The output of the Java code, assuming that all variables are properly declared, is 32. num = 10; while (num <= 32) num = num + 5; System.out.println(num);
True False
Answer:
Tags
Choose question tag
close menu
arrow
In the case of an infinite while loop, the while expression (that is, the loop condition) is always true.
True False
Answer:
Tags
Choose question tag
close menu
arrow
To read data from a file of unspecified length, an EOF-controlled while loop is a better choice than a counter-controlled while loop.
True False
Answer:
Tags
Choose question tag
close menu
arrow
The control statements in the for loop include the initial expression, logical expression, and update expression.
True False
Answer:
Tags
Choose question tag
close menu
arrow
Assume that all variables in the following code are properly declared and that the input is 3 7 4 -1. The output is 13. num = console.nextInt(); sum = num; while (num != -1) {num = console.nextInt(); sum = sum + num;} System.out.println(sum);
True False
Answer:
Tags
Choose question tag
close menu
arrow
In the for statement, if the logical expression is omitted, it is assumed to be false.
True False
Answer:
Tags
Choose question tag
close menu
arrow
A syntax error will result if the control statements of a for loop are omitted.
True False
Answer:
Tags
Choose question tag
close menu
arrow
A loop that continues to execute endlessly is called an endless loop.
True False
Answer:
Tags
Choose question tag
close menu
arrow
The loop condition of a while loop is reevaluated before every iteration of the loop.
True False
Answer:
Tags
Choose question tag
close menu
arrow
If the while expression becomes false in the middle of the while loop body, the loop terminates immediately.
True False
Answer:
Tags
Choose question tag
close menu
arrow
EOF-controlled while loop is another name for sentinel-controlled while loop.
True False
Answer:
Tags
Choose question tag
close menu
arrow
A counter-controlled loop is used when the exact number of data entries is known.
True False
Answer:
Tags
Choose question tag
close menu
arrow
Control variables are automatically initialized in a loop.
True False
Answer:
Tags
Choose question tag
close menu
arrow
A while loop is a post-test loop.
True False
Answer:
Tags
Choose question tag
close menu
arrow
The output of the following Java code is: Stoor. int count = 5; System.out.print("Sto"); do {System.out.print('o'); count--;} while (count >= 5); System.out.println('r');
True False
Answer:
Tags
Choose question tag
close menu
arrow
Like a do...while loop, the body of a while loop executes at least once.
True False
Answer:
Tags
Choose question tag
close menu
arrow
The output of the Java code, assuming that all variables are properly declared, is: 2 3 4 5 6. n = 2; while (n >= 6) {System.out.print(n + " "); n++;} System.out.println();
True False
Answer:
Tags
Choose question tag
close menu
Showing 1 - 20 of 50