Quiz05.05-09 - Vernon Computer Science

advertisement

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

10.

11.

12.

13.

6.

7.

8.

9.

1.

2.

3.

4.

5.

19.

20.

21.

22.

23.

24.

25.

EC.

14.

15.

16.

17.

18.

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.

Conditional Branching

II. Decision Making

III. Iteration

IV. Looping

(a) I and II

(b) I and III

(c) I and IV

(d) II and III

(e) II and IV

(f) 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) one-way selection

(B) two-way selection

(C) multiple-way selection

(D) fixed repetition

(E) 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) one-way selection

(B) two-way selection

(C) multiple-way selection

(D) fixed repetition

(E) 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) one-way selection

(B) two-way selection

(C) multiple-way selection

(D) fixed repetition

(E) 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) one-way selection

(B) two-way selection

(C) multiple-way selection

(D) fixed repetition

(E) 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) one-way selection

(B) two-way selection

(C) multiple-way selection

(D) fixed repetition

(E) conditional repetition

Question 11

The one-way selection control structure uses the _____ keyword.

(A) if

(B) else

(C) for

(D) while

(E) switch

Question 12

The two-way selection control structure uses the _____ keyword.

(A) do

(B) else

(C) for

(D) while

(E) switch

Question 13

The multiple-way selection control structure uses the _____ keyword.

(A) if

(B) else

(C) for

(D) while

(E) switch

Question 14

The fixed repetition control structure uses the _____ keyword.

(A) if

(B) else

(C) for

(D) while

(E) switch

Question 15

The conditional repetition control structure uses the _____ keyword.

(A) if

(B) else

(C) for

(D) while

(E) 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.

boolean

II. char

III. double

IV. int

V. String

(a) I only

(b) II only

(c) II and IV only

(d) II and V only

(e) III and IV only

(f) II, IV and V only

(g) I, II, III, IV & V

Question 22

Which of these commands is used with switch ?

I.

case

II. break

III. default

(a) I only

(b) I and II only

(c) I and III only

(d) II and III only

(e) I, II and III

Question 23

How do you control multiple program statements with an if , for or while control structure?

(A) Put the statements inside parentheses ( ).

(B) Put the statements inside brackets [ ].

(C) Put the statements inside angle brackets < >.

(D) Put the statements inside braces { }.

Question 24

A for loop needs a counter .

What is technical name for this counter ?

(A) Loop Counting Constant

(B) Loop Control Constant

(C) Loop Counting Variable

(D) Loop Control Variable

(E) There is none. It’s just called a counter .

Question 25

When creating a loop, what is the flag ?

(A) A special value that makes the loop start

(B) A special value that makes the loop stop

(C) A special value that makes the loop continue

(D) 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

Download