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 Input/output50 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 Classes50 Questions
Exam 9: Arrays46 Questions
Exam 10: Inheritance and Polymorphism50 Questions
Exam 11: Handling Exceptions and Events50 Questions
Exam 12: Advanced Guis and Graphics48 Questions
Exam 13: Recursion50 Questions
Exam 14: Applications of Arrays Searching and Sorting and Strings50 Questions
Select questions type
In the for statement, if the logical expression is omitted, it is assumed to be false.
(True/False)
4.8/5
(36)
A loop that continues to execute endlessly is called an endless loop.
(True/False)
4.9/5
(44)
int x = 27;
Int y = 10;do
X = x / 3;
While (x >= y);How many times does the statement above execute?
(Multiple Choice)
4.7/5
(36)
int sum = 0;int limit = console.nextInt();
Int counter = 0;while (counter <= limit){
Entry = console.nextInt();
Sum = sum + entry;
Counter++;
}The above code is an example of a(n) ____ while loop.
(Multiple Choice)
4.8/5
(39)
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.7/5
(39)
EOF-controlled while loop is another name for sentinel-controlled while loop.
(True/False)
4.9/5
(30)
Like a do...while loop, the body of a while loop executes at least once.
(True/False)
4.7/5
(44)
Because a do...while loop is a post-test loop, the body of the loop may not execute at all.
(True/False)
4.9/5
(40)
A loop is a control structure that causes certain statements to be executed over and over until certain conditions are met.
(True/False)
4.9/5
(29)
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.9/5
(31)
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
(33)
If the while expression becomes false in the middle of the while loop body, the loop terminates immediately.
(True/False)
4.8/5
(34)
Suppose sum and num are int variables, and the input is
20 25 10 18 -1 What is the output of the following code? (Assume that console is a Scanner object initialized to the standard input device.)sum = 0;
Num = console.nextInt();
While (num != -1)
{
If (num >= 20)
Sum = sum + num;
Else
Sum = sum - num;
Num = console.nextInt();
}
System.out.println(sum);
(Multiple Choice)
4.8/5
(48)
int x = 27;
Int y = 10;do
X = x / 3;
While (x >= y);If y = 0, how many times would the loop above execute?
(Multiple Choice)
4.8/5
(39)
A counter-controlled loop is used when the exact number of data entries is known.
(True/False)
4.7/5
(38)
After a break statement executes, the program continues to execute with the first statement after the structure.
(True/False)
4.9/5
(38)
int i;for (i = 0; i <= 10; i++)
System.out.println("*");
System.out.println("!");Which of the following is the logical expression in the for loop above?
(Multiple Choice)
4.9/5
(42)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)