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
The control statements in the for loop include the initial expression, logical expression, and update expression.
Free
(True/False)
4.8/5
(42)
Correct Answer:
True
In the case of an infinite while loop, the while expression (that is, the loop condition) is always true.
Free
(True/False)
4.9/5
(35)
Correct Answer:
True
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
(43)
The loop condition of a while loop is reevaluated before every iteration of the loop.
(True/False)
4.8/5
(27)
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
(36)
boolean found = false;
Int num;
Int square;while (!found)
{
Num = console.nextInt();
Square = num * num;
If (square > 40)
Found = true;
}The above code is an example of a(n) ____ loop.
(Multiple Choice)
4.8/5
(40)
ch = inFile.next().charAt();while (inFile.hasNext())
{
System.out.println(ch);
Ch = inFile.next().charAt();
}The above code is an example of a(n) ____ loop.
(Multiple Choice)
4.7/5
(36)
What is value of x after the following code executes?int x = 0;
Int i;for (i = 0; i < 5; i++)
X = 3 * x + i;
(Multiple Choice)
4.7/5
(44)
int i;for (i = 0; i <= 10; i++)
System.out.println("*");
System.out.println("!");Which of the following is the update expression in the for loop above?
(Multiple Choice)
4.8/5
(38)
Which executes immediately after a continue statement in a for loop?
(Multiple Choice)
4.9/5
(31)
int x = 27;
Int y = 10;do
X = x / 3;
While (x >= y);What is the final value of x in the code above?
(Multiple Choice)
4.8/5
(33)
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)
4.8/5
(35)
A break statement is legal in a while loop, but not in a for loop.
(True/False)
4.9/5
(32)
What is the output of the following Java code?int num = 15;
While (num > 0)
Num = num - 3;
System.out.println(num);
(Multiple Choice)
4.9/5
(35)
What is the value of counter after the following statements execute?counter = 1;
While (counter<30)
Counter = 2 * counter;
(Multiple Choice)
5.0/5
(38)
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.
(True/False)
4.8/5
(43)
int i;for (i = 0; i <= 10; i++)
System.out.println("*");
System.out.println("!");Which of the following is the initial expression in the for loop above?
(Multiple Choice)
4.9/5
(32)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)