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
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.9/5
(37)
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.8/5
(34)
A syntax error will result if the control statements of a for loop are omitted.
(True/False)
4.8/5
(44)
If a continue statement is placed in a do...while structure, the loop-continue test is evaluated immediately after the continue statement.
(True/False)
4.8/5
(36)
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.7/5
(34)
What is the value of counter after the following statements execute? counter = 1; while (counter < 30) counter = 2 * counter;
(Multiple Choice)
4.9/5
(37)
Which executes immediately after a continue statement in a for loop?
(Multiple Choice)
4.7/5
(36)
Which of the following loops is guaranteed to execute at least once?
(Multiple Choice)
4.7/5
(40)
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.7/5
(38)
A break statement is legal in a while loop, but not in a for loop.
(True/False)
4.7/5
(39)
Showing 21 - 40 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)