wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

APCSA Final

Total questions: 28

Worksheet time: 2hrs 20mins

Name
Class
Date
1.

What would be displayed after the following code is run?

a)

2

b)

-4

c)

14

d)

4

2.

Determine what is printed by the following code.

a)

8

b)

-16

c)

-12

d)

16

3.

A student wrote the procedure below, which is intended to ask whether a user wants to keep playing a game. The procedure does not work as intended. Which of the following best describes the result of running the procedure?

a)

The procedure returns TRUE when the user inputs the value "y" and returns FALSE otherwise.

b)

The procedure returns TRUE when the user inputs the value "n" and returns FALSE otherwise.

c)

The procedure returns TRUE no matter what the input is.

d)

The procedure returns FALSE no matter what the input is.

4.

Determine what is printed by the following code.

a)

2 1 5

b)

9 1 6

c)

10 4 6

d)

10 1 6

5.

A program is created to perform arithmetic operations on positive and negative integers. The program contains the following incorrect procedure, which is intended to return the product of the integers x and y. A programmer suspects that an error in the program is caused by this procedure. Under which of the following conditions will the procedure NOT return the correct product? SELECT TWO ANSWERS:

a)

When the values of x and y are both.

b)

When the value of x is positive and the value of y is negative.

c)

When the value of x is negative and the value of y is positive.

d)

When the values of x and y are both negative.

6.

a)
b)
c)
d)
7.

In the program below, the initial value of X is 5 and the initial value of Y is 10. What is displayed as a result of running the program?

a)

Foxtrot

b)

Hotel

c)

November

d)

Yankee

8.

a)
b)
c)
d)
9.

a)
b)
c)
d)
10.

The question below uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing toward the top of the grid. Code for the procedure Mystery is shown below. Assume that the parameter p has been assigned a positive integer value (e.g. 1,2,3...) Which of the following shows a POSSIBLE result of calling the procedure?

a)
b)
c)
d)
11.

a)
b)
c)
d)
12.

a)

Program I displays the correct sum, but Program II does not.

b)

Program II displays the correct sum, but Program I does not.

c)

Both Program I and Program II display the correct sum.

d)

Neither Program I nor Program II displays the correct sum.

13.

a)
b)
c)
d)
14.

a)
b)
c)
d)
15.

a)
b)
c)
d)
16.

a)
b)
c)
d)
17.

a)
b)
c)
d)
18.

Which of the following code segments can be used to move the robot to the gray square?

a)
b)
c)
d)
19.

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

a)

10

b)

20

c)

30

d)

40

20.

What would be the output from the code show here?

a)
b)
c)
d)
21.

What would be the output from the code show here?

a)
b)
c)
d)
22.

What would appear in the canvas if the following code is run?

a)
b)
c)
d)
23.

Which code shows the correct way to set a shapes position at the center of the canvas?

a)
b)
c)
d)
24.

What will be displayed as a result of this code?

a)

The result is: 31

b)

The result is: 10

c)

The result is: + expression

d)

The result is: 80

25.

Consider the following program, which uses the variables START, END, and CURRENT. What is displayed as a result of executing the program?

a)

1 3

b)

3 3

c)

3 4

d)

4 4

26.

Consider the following code segment, which moves the robot in the grid. Which of the following shows the location of the robot after running the code segment?

a)
b)
c)
27.

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

a)

10 20 30 40

b)

21 30 40 50

c)

21 40 30 40

d)

21 40 30 50

28.

The following question uses a robot in a grid of squares. The robot is represented by a triangle, which is initially facing toward the top of the grid. Which of the following code segments will move the robot to the gray square along the path indicated by the arrows?

a)
b)
c)
d)