Exam 5: Control Structures II: Repetition
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of Java50 Questions
Exam 3: Introduction to Objects and Inputoutput50 Questions
Exam 4: Control Structures I: Selection50 Questions
Exam 5: Control Structures II: Repetition50 Questions
Exam 6: Graphical User Interface Gui and Object-Oriented Design OOD50 Questions
Exam 7: User-Defined Methods50 Questions
Exam 8: User-Defined Classes and Adts50 Questions
Exam 9: Arrays50 Questions
Exam 10: Inheritance and Polymorphism50 Questions
Exam 11: Handling Exceptions and Events50 Questions
Exam 12: Advanced Guis and Graphics49 Questions
Exam 13: Recursion50 Questions
Exam 14: Searching and Sorting50 Questions
Select questions type
The do...while loop has an exit condition but no entry condition.
Free
(True/False)
4.9/5
(41)
Correct Answer:
True
Which of the following is true about a while loop?
Free
(Multiple Choice)
4.9/5
(31)
Correct Answer:
C
If y = 0, how many times would the loop above execute?
Free
(Multiple Choice)
4.7/5
(41)
Correct Answer:
D
The loop condition of a while loop is reevaluated before every iteration of the loop.
(True/False)
4.8/5
(33)
The control statements in the for loop include the initial expression, logical expression, and update expression.
(True/False)
4.9/5
(37)
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.
(True/False)
4.9/5
(40)
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)
4.8/5
(36)
Which of the following is not a function of the break statement?
(Multiple Choice)
4.9/5
(43)
In the for statement, if the logical expression is omitted, it is assumed to be false.
(True/False)
4.8/5
(33)
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);
(True/False)
4.9/5
(33)
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)
4.8/5
(45)
Which of the following is the logical expression in the for loop above?
(Multiple Choice)
4.8/5
(43)
A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met.
(True/False)
5.0/5
(45)
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)
4.8/5
(45)
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)
4.9/5
(37)
Which of the following is the update expression in the for loop above?
(Multiple Choice)
4.8/5
(33)
What is the output of the following code? int count; int num = 2; for (count = 1; count < 2; count++) {num = num + 3; System.out.print(num + " ");} System.out.println();
(Multiple Choice)
4.8/5
(46)
Which of the following is the initial expression in the for loop above?
(Multiple Choice)
4.9/5
(28)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)