Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP Comp Sci AP Exam Review

Total questions: 48

Worksheet time: 38mins

Name
Class
Date
1.

In a certain video game, players are awarded bonus points at the end of a level based on the value of the integer variable timer. The bonus points are awarded as follows: - If timer is less than 30, then 500 bonus points are awarded. - If timer is between 30 and 60 inclusive, then 1000 bonus points are awarded. - If timer is greater than 60, then 1500 bonus points are awarded. Which of the following code segments assigns the correct number of bonus points to bonus for all possible values of timer?

a)

A

b)

B

c)

d)

2.

Based on the flowchart, what is the final value of the bonus if the timer is 45?

a)

500

b)

1000

c)

1500

d)

2000

3.

The grid below contains a robot represented as a triangle, initially facing up. The robot can move into a white or gray square but cannot move into a black region. The code segment below uses the procedure GoalReached, which evaluates to true if the robot is in the gray square and evaluates to false otherwise. Which of the following replacements for can be used to move the robot to the gray square?

a)

IF (CAN_MOVE (forward)) { MOVE_FORWARD () ROTATE_RIGHT () }

b)

IF (CAN_MOVE (right)) { ROTATE_RIGHT () MOVE_FORWARD () }

c)

IF (CAN_MOVE (forward)) { MOVE_FORWARD () } ROTATE_RIGHT ()

d)

IF (CAN_MOVE (right)) { (ROTATE_RIGHT) } MOVE_FORWARD ()

4.

Consider the following code segment. What are the values of first and second as a result of executing the code segment?

a)

first = 100, second = 100

b)

first = 200, second = 100

c)

first = 100, second = 200

d)

first = 200, second = 200

5.

Consider the following code segment. What are the values of first and second as a result of executing the code segment?

a)

The value of first is true, and the value of second is true.

b)

The value of first is true, and the value of second is false.

c)

The value of first is false, and the value of second is true.

d)

The value of first is false, and the value of second is false.

6.

Consider the following code segment. x ← 25 y ← 50 z ← 75 x ← y y ← z z ← x Which of the variables have the value 50 after executing the code segment?

a)

x only

b)

y only

c)

x, y, and z

d)

x and z only

7.

Consider the following code segment. What is the value of r as a result of executing the code segment?

a)

20

b)

30

c)

40

d)

10

8.

A game is played by moving a game piece left or right along a horizontal game board. The board consists of spaces of various colors, as shown. The circle represents the initial location of the game piece. The following algorithm indicates how the game is played. The game continues until the game is either won by landing on the red space or lost when the piece moves off either end of the board. Step 1: Place a game piece on a space that is not red and set a counter to 0. Step 2: If the game piece is on a yellow space, move the game piece 3 positions to the left and go to step 3. Otherwise, if the game piece is on a black space, move the game piece 1 position to the left and go to step 3. Otherwise, if the game piece is on a green space, move the game piece 2 positions to the right and go to step 3. Step 3: Increase the value of the counter by 1. Step 4: If game piece is on the red space or moved off the end of the game board, the game is complete. Otherwise, go back to step 2. If a game is begun by placing the game piece on the rightmost black space for step 1, what will be the value of the counter at the end of the game?

a)

3

b)

4

c)

2

d)

1

9.

The grid below contains a robot represented as a triangle, initially facing toward the top of the grid. The robot can move into a white or gray square but cannot move into a black region.

a)

IF(CAN_MOVE(left))

{

ROTATE_LEFT()

MOVE_FORWARD()

}

b)

IF(CAN_MOVE(left))

{

ROTATE_LEFT()

}

MOVE_FORWARD()

10.

A byte =

a)

8 Bits

b)

4 Bits

c)

9 Bits

d)

6 Bits

11.

Error from attempting to represent a number that is too large.

a)

Binary

b)

Overflow Error

c)

Round-off Error

12.

Error from attempting to represent a number that is too precise. The value is rounded.

a)

Binary

b)

Overflow Error

c)

Round-off Error

13.

A way of representing information using only two options.

a)

Binary

b)

Round-off Error

c)

Overflow Error

14.

Consider the following code segment. x ← 10 y ← 20 z ← 30 x ← z z ← y y ← x Which of the variables have the value 30 after executing the code segment?

a)

z only

b)

x only

c)

x and y only

d)

y only

15.

After running the program what is the value of Start?

(a)  

16.

After running the program what is the value of Current?

(a)  

17.

The following program is run. Then the user clicks the "bottomButton" ONCE and then clicks the "topButton" ONCE. What will be displayed in the console?

a)

chicken pig cow

b)

cow pig chicken

c)

cow chicken pig

d)

pig cow chicken

18.

data that are sent to a computer for processing by a program. Can come in a variety of forms, such as tactile interaction, audio, visuals, or text.

a)

input

b)

user interface

c)

event driven processing

d)

debugging

e)

development process

19.

the inputs and outputs that allow a user to interact with a piece of software. User interfaces can include a variety of forms such as buttons, menus, images, text, and graphics.

a)

input

b)

user interface

c)

event driven processing

d)

debugging

e)

development process

20.

the steps or phases used to create a piece of software. Typical phases include investigating, designing, prototyping, and testing

a)

input

b)

user interface

c)

event driven processing

d)

debugging

e)

development process

21.

some program statements run when triggered by an event, like a mouse click or a key press

a)

input

b)

user interface

c)

event driven processing

d)

debugging

e)

development process

22.

program statements run in order, from top to bottom

a)

input

b)

user interface

c)

event driven processing

d)

Sequential Programming

e)

development process

23.

a command or instruction. Sometimes also referred to as a code statement

a)

input

b)

user interface

c)

event driven processing

d)

Sequential Programming

e)

program Statement

24.

Which of the following expressions are equivalent to the value of expression as shown in the table?

Select two answers.

a)

(NOT input1) OR (NOT input2)

b)


(NOT input1) AND (NOT input2)

c)

NOT (input1 OR input2)

d)

NOT (input1 AND input2)

25.
  • In column B, the price range represents the typical cost of a meal, where "lo" indicates under $10, "med" indicates $11 to $30, and "hi" indicates over $30.

  • In column D, the average customer rating is set to -1.0 for restaurants that have no customer ratings.

A student wants to count the number of restaurants in the spreadsheet whose price range is $30 or less and whose average customer rating is at least 4.0. For a given row in the spreadsheet, suppose prcRange contains the price range as a string and avgRating contains the average customer rating as a decimal number.

Which of the following expressions will evaluate to true if the restaurant should be counted and evaluates to false otherwise?

a)

(avgRating ≥ 4.0) AND ((prcRange = "lo") AND (prcRange = "med"))

b)

(avgRating ≥ 4.0) AND ((prcRange = "lo") OR (prcRange = "med"))

c)

(avgRating ≥ 4.0) OR ((prcRange = "lo") AND (prcRange = "med"))

d)


(avgRating ≥ 4.0) OR ((prcRange = "lo") OR (prcRange = "med"))

26.

Which of the following Boolean expressions are equivalent to the expression num>= 15 ?

Select two answers.

a)

(num > 15) and (num = 15)

b)

(num > 15) or (num = 15)

c)

NOT (num < 15)

d)

NOT (num < 16 )

27.

The cost of a customer’s electricity bill is based on the number of units of electricity the customer uses.

  • For the first 25 units of electricity, the cost is $5 per unit.

  • For units of electricity after the first 25, the cost is $7 per unit.

Which of the following code segments correctly sets the value of the variable cost to the cost, in dollars, of using numUnits units of electricity?

a)

b)

c)

d)

28.

A color in a computing application is represented by an RGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10).

According to information in the table, what color is represented by the binary RGB triplet (11111111, 11111111, 11110000) ?

a)

Ivory

b)

vivid yellow

c)

indigo

d)

pale yellow

e)

magenta

29.

A color in a computing application is represented by an RGB triplet that describes the amount of red, green, and blue, respectively, used to create the desired color. A selection of colors and their corresponding RGB triplets are shown in the following table. Each value is represented in decimal (base 10).

What is the binary RGB triplet for the color indigo?

a)

(00100101, 00000000, 10000010)

b)

(00100101, 00000000, 01000001)

c)

(01001011, 00000000, 10000010)

d)

(01001011, 00000000, 01000001)

30.

What is the value of x after this code runs?


int x = 5;

x = 10;

x = 4;

a)

5

b)

10

c)

4

d)

true

31.

A programmer is creating an algorithm that will be used to turn on the motor to open the gate in a parking garage. The specifications for the algorithm are as follows.

  • The gate should not open when the time is outside of business hours.

  • The motor should not turn on unless the gate sensor is activated.

  • The motor should not turn on if the gate is already open.

Which of the following algorithms can be used to open the gate under the appropriate conditions?

a)

Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor.

b)


Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is, turn on the motor.

c)

Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is not, check if the gate is open. If it is not, turn on the motor.

d)

Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.

32.

Which of the following statements is equivalent to the algorithm in the flowchart?

a)

include <- (floor > 10) or (bedrooms = 3)

b)

include <- (floor > 10) and (bedrooms = 3)

c)

include <- (floor <= 10) or (bedrooms = 3)

d)

include <- (floor <= 10) and (bedrooms = 3)

33.

Consider the following code segment, which uses the variables r, s, and t.

r ← 1

s ← 2

t ← 3

r ← s

s ← t

DISPLAY (r)

DISPLAY (s)

What is displayed as a result of running the code segment?

(a)  

34.

Which of the following Boolean expressions are equivalent to the expression num >= 15 ?

a)

( num > 15 ) and ( num = 15)

b)

( num > 15 ) or ( num = 15)

c)

not ( num < 15 )

d)

not ( num < 16 )

35.

If the inputs A and C are both true, which of the following best describes the output of the AND gate?

a)

The output will be true no matter what the value of input B is

b)

The output will be false no matter what the value of input B is.

c)

The output will be true if input B is true; otherwise it will be false.

d)

The output will be false if input B is true; otherwise it will be true.

36.

Which of the following school policies is most likely to have a positive impact on the digital divide?

a)

A school allows students to bring a graphing calculator from home to complete in-class mathematics assignments.

b)

A school allows students to bring a tablet computer to class every day to participate in graded quizzes.

c)

A school provides a laptop or tablet computer to all students enrolled at the school.

d)

A school recommends that all students purchase a computer with as much processing speed as possible so that projects run faster.

37.

An online store uses 6-bit binary sequences to identify each unique item for sale. The store plans to increase the number of items it sells and is considering using 7-bit binary sequences. Which of the following best describes the result of using 7-bit sequences instead of 6-bit sequences?

a)

2 more items can be uniquely identified.

b)

10 more items can be uniquely identified.

c)

2 times as many items can be uniquely identified.

d)

10 times as many items can be uniquely identified.

38.

For which of the following lists can a binary search be used to search for an item in the list?

a)

I only

b)

III only

c)

I and III only

d)

I, II, and III

39.

A student is recording a song on her computer. When the recording is finished, she saves a copy on her computer. The student notices that the saved copy is of lower sound quality than the original recording. Which of the following could be a possible explanation for the difference in sound quality?

a)

The song was saved using fewer bits per second than the original song.

b)

The song was saved using more bits per second than the original song.

c)

The song was saved using a lossless compression technique.

d)

Some information is lost every time a file is saved from one location on a computer to another location.

40.
a)

True

b)

False

41.

a)

True

b)

False

42.

What gets logged to the console?

a)

[1, 2, 3, 4, 5]

b)

1

c)

myList

d)

2

43.

What gets logged to the console?

a)

[1, 2, 3, 4, 5]

b)

1

c)

myList

d)

error

44.

What is displayed to the console log?

a)

$10

b)

$ 10

c)

$10.00

d)

error

45.

What base is binary in?

a)

2

b)

4

c)

1

d)

7

46.

How would you represent the number 5 in binary?

a)

10

b)

100

c)

101

d)

110

47.

What number does 110 represent in binary?

a)

6

b)

3

c)

8

d)

12

48.

What two numbers do we use in binary?

a)

-1 & 0

b)

2 & 1

c)

1 & 0

d)

4 & 0