Quiz05.05-09 - Vernon Computer Science

Download Report

Transcript Quiz05.05-09 - Vernon Computer Science

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.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
EC.
Question 01
Which of these is a real-life example of two-way selection?
(a)
(d)
(b)
(c)
Question 02
Which of these is a real-life example of multi-way selection?
(a)
(d)
(b)
(c)
Question 03
Which of these is a real-life example of fixed repetition?
(a)
(d)
(b)
(c)
Question 04
Which of these is a real-life example of conditional repetition?
(a)
(d)
(b)
(c)
Question 05
Repetition is also called
I.
II.
III.
IV.
Conditional Branching
Decision Making
Iteration
Looping
(a)
(b)
(c)
(d)
(e)
(f)
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;
(A)
(B)
(C)
(D)
(E)
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.");
(A)
(B)
(C)
(D)
(E)
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();
}
(A)
(B)
(C)
(D)
(E)
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;
}
(A)
(B)
(C)
(D)
(E)
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");
(A)
(B)
(C)
(D)
(E)
one-way selection
two-way selection
multiple-way selection
fixed repetition
conditional repetition
Question 11
The one-way selection control structure uses
the _____ keyword.
(A)
(B)
(C)
(D)
(E)
if
else
for
while
switch
Question 12
The two-way selection control structure uses
the _____ keyword.
(A)
(B)
(C)
(D)
(E)
do
else
for
while
switch
Question 13
The multiple-way selection control structure uses
the _____ keyword.
(A)
(B)
(C)
(D)
(E)
if
else
for
while
switch
Question 14
The fixed repetition control structure uses
the _____ keyword.
(A)
(B)
(C)
(D)
(E)
if
else
for
while
switch
Question 15
The conditional repetition control structure uses
the _____ keyword.
(A)
(B)
(C)
(D)
(E)
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;
case 'C' : System.out.println("balance inquiry");
}
Question 17
True or False:
One problem with the switch command
is that each case can only control a
single programming statement.
(a) True
(b) False
Question 18
True or False:
break must always be used with default.
(a) True
(b) False
Question 19
True or False:
If your switch structure does not use
default, then you do not need a break
after the last case.
(a) True
(b) False
Question 20
True or False:
In a switch structure, multiple cases can
yield the same outcome.
(a) True
(b) False
Question 21
Which of these data types work with switch?
I.
II.
III.
IV.
V.
boolean
char
double
int
String
(a)
(b)
(c)
(d)
(e)
(f)
(g)
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?
I. case
II. break
III. default
(a)
(b)
(c)
(d)
(e)
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?
(A)
(B)
(C)
(D)
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?
(A)
(B)
(C)
(D)
(E)
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)
(B)
(C)
(D)
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);
(A) 109
(B) 110
(C) 124
(D) 127
(E) 130