Services
Discover
Homeschooling
Ask a Question
Log in
Sign up
Filters
Done
Question type:
Essay
Multiple Choice
Short Answer
True False
Matching
Topic
Computing
Study Set
Java How To Program
Quiz 5: Control Statements: Part 2
Path 4
Access For Free
Share
All types
Filters
Study Flashcards
Practice Exam
Learn
Question 1
Multiple Choice
Which formatting flag indicates that the floating-point values should be output with a thousands separator?
Question 2
Multiple Choice
Which of the following statements about the break statement is false?
Question 3
Multiple Choice
For the two code segments below: Segment A Int q = 5; Switch(q) { Case 1: System.out.println(1) ; Case 2: System.out.println(2) ; Case 3: System.out.println(3) ; Case 4: System.out.println(4) ; Case 5: System.out.println(5) ; Default: System.out.println("default") ; } Segment B Q = 4; Switch(q) { Case 1: System.out.println(1) ; Case 2: System.out.println(2) ; Case 3: System.out.println(3) ; Case 4: System.out.println(4) ; Case 5: System.out.println(5) ; Default: System.out.println("default") ; } Which of the following statements is true?
Question 4
Multiple Choice
Which statement prints the floating-point value 123.456 right justified with a field width of 10?
Question 5
Multiple Choice
Which of the following can be used in a switch statement in the expression after keyword case? a) a constant integral expression. b) a character constant. c) a String d) an enumeration constant.
Question 6
Multiple Choice
Which of the following statements about the continue statement is true?
Question 7
Multiple Choice
Consider the classes below: Public class TestA { Public static void main(String args[]) { Int x = 2; Int y = 20 Int counter = 0; For (int j = y % x;j < 100;j += (y / x) ) Counter++; } } Public class TestB { Public static void main(String args[]) { Int counter = 0; For (int j = 10;j > 0;--j) ++counter; } } Which of the following statements is true?
Question 8
Multiple Choice
Consider the code segment below. If (gender == 1) { If (age >= 65) ++seniorFemales; } This segment is equivalent to which of the following?
Question 9
Multiple Choice
For the code segment below: Switch(q) { Case 1: System.out.println("apple") ; Break; Case 2: System.out.println("orange") ; Break; Case 3: System.out.println("banana") ; Break; Case 4: System.out.println("pear") ; Case 5: System.out.println("grapes") ; Default: System.out.println("kiwi") ; } Which of the following values for q will result in kiwi being included in the output?
Question 10
Multiple Choice
Which of the following will count down from 10 to 1 correctly?
Question 11
Multiple Choice
Which of the following for-loop headers results in equivalent numbers of iterations: a) for (int q = 1;q <= 100;q++) b) for (int q = 100;q >= 0;q--) c) for (int q = 99;q > 0;q -= 9) d) for (int q = 990;q > 0;q -= 90)
Question 12
Multiple Choice
Which of the following is equivalent to this code segment? Int total = 0; For (int i = 0;i <= 20;i += 2) Total += i;
Question 13
Multiple Choice
Counter-controlled repetition requires
Question 14
Multiple Choice
Which of the following will not help prevent infinite loops?
Question 15
Multiple Choice
Which of the following statements is true?
Question 16
Multiple Choice
The control variable of a counter-controlled loop should be declared as ________to prevent errors.
Question 17
Multiple Choice
To exit out of a loop completely,and resume the flow of control at the next statement after the loop,use a _______.
Question 18
Multiple Choice
Which of the following statements about a do…while repetition statement is true?
Question 19
Multiple Choice
Consider the following two Java code segments: Segment 1 Segment 2 Int i = 0; For (int i = 0;i <= 20;i++) While (i < 20) { { System.out.println(i) ; I++;} System.out.println(i) ; } Which of the following statements are true?