PreAP Computer Science Quiz 05.05- 09 Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 30 seconds per question.
Title the quiz as shown below The quiz starts in ONE minute. Name Period Date Quiz 05.05-09 1. 14. 2. 15. 3. 16. 4. 17. 5. 18. 6. 19. 7. 20. 8. 21. 9. 22. 10. 23. 11. 24. 12. 25. 13. EC.
Question 01 Which of these is a real-life example of two-way selection? (a) (b) (c) (d)
Question 02 Which of these is a real-life example of multi-way selection? (a) (b) (c) (d)
Question 03 Which of these is a real-life example of fixed repetition? (a) (b) (c) (d)
Question 04 Which of these is a real-life example of conditional repetition? (a) (b) (c) (d)
Question 05 Repetition is also called I and II Conditional Branching Decision Making Iteration Looping I and II I and III I and IV II and III II and IV III and IV
Question 06 What type of control structure is used by the following program segment? double allowance = 20.0; if (grades >= 80) allowance += 10.0; one-way selection two-way selection multiple-way selection fixed repetition conditional repetition
Question 07 What type of control structure is used by the following program segment? for (int k = 1; k <= 100; k++) System.out.println("I will chew gum properly."); one-way selection two-way selection multiple-way selection fixed repetition conditional repetition
Question 08 What type of control structure is used by the following program segment? int pin = 0; while (pin != 54321) { System.out.print("Enter your 5-digit PIN ===>> "); pin = Expo.enterInt(); } one-way selection two-way selection multiple-way selection fixed repetition conditional repetition
Question 09 What type of control structure is used by the following program segment? switch (selection) { case 'A' : System.out.println("deposit"); break; case 'B' : System.out.println("withdrawal"); break; case 'C' : System.out.println("balance inquiry"); break; } one-way selection two-way selection multiple-way selection fixed repetition conditional repetition
Question 10 What type of control structure is used by the following program segment? if (sat < 1250) System.out.println("You are not admitted"); else System.out.println("You are admitted"); one-way selection two-way selection multiple-way selection fixed repetition conditional repetition
Question 11 The one-way selection control structure uses the _____ keyword. if else for while switch
Question 12 The two-way selection control structure uses the _____ keyword. do else for while switch
Question 13 The multiple-way selection control structure uses the _____ keyword. if else for while switch
Question 14 The fixed repetition control structure uses the _____ keyword. if else for while switch
Question 15 The conditional repetition control structure uses the _____ keyword. if else for while switch
Question 16 Which of these switch structures will have a strange output? switch (selection) // choice (a) { case 'A' : System.out.println("deposit"); case 'B' : System.out.println("withdrawal"); case 'C' : System.out.println("balance inquiry"); } switch (selection) // choice (b) case 'A' : System.out.println("deposit"); break; case 'B' : System.out.println("withdrawal"); break;
Question 17 True or False: One problem with the switch command is that each case can only control a single programming statement. True False
Question 18 True or False: break must always be used with default.
Question 19 True or False: If your switch structure does not use default, then you do not need a break after the last case. True False
Question 20 True or False: In a switch structure, multiple cases can yield the same outcome. True False
Question 21 Which of these data types work with switch? boolean I only char double int String I only II only II and IV only II and V only III and IV only II, IV and V only I, II, III, IV & V
Question 22 Which of these commands is used with switch? case I only break default I only I and II only I and III only II and III only I, II and III
Question 23 How do you control multiple program statements with an if, for or while control structure? Put the statements inside parentheses ( ). Put the statements inside brackets [ ]. Put the statements inside angle brackets < >. Put the statements inside braces { }.
Question 24 A for loop needs a counter. What is technical name for this counter? Loop Counting Constant Loop Control Constant Loop Counting Variable Loop Control Variable There is none. It’s just called a counter.
Question 25 When creating a loop, what is the flag? A special value that makes the loop start A special value that makes the loop stop A special value that makes the loop continue A special value that never changes in the loop
Extra Credit What is the output of the following segment? int count = 100; for (int k = 1; k < 10; k++) count = count + 3; System.out.println(count); 109 110 124 127 130