
AP Comp Sci AP Exam Review
Authored by C Swain
Computers
9th - 12th Grade
Used 11+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
48 questions
Show all answers
1.
MULTIPLE SELECT QUESTION
2 mins • 2 pts
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?
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Based on the flowchart, what is the final value of the bonus if the timer is 45?
500
1000
1500
2000
Answer explanation
According to the flowchart, when the timer is 45, the bonus is set to 1000. Therefore, the final value of the bonus is 1000.
3.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
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
IF (CAN_MOVE (forward)) { MOVE_FORWARD () ROTATE_RIGHT () }
IF (CAN_MOVE (right)) { ROTATE_RIGHT () MOVE_FORWARD () }
IF (CAN_MOVE (forward)) { MOVE_FORWARD () } ROTATE_RIGHT ()
IF (CAN_MOVE (right)) { (ROTATE_RIGHT) } MOVE_FORWARD ()
Answer explanation
The correct choice is to rotate right and then move forward. This allows the robot to face the gray square directly and move into it, as it cannot move forward initially due to the black region in front.
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment. What are the values of first and second as a result of executing the code segment?
first = 100, second = 100
first = 200, second = 100
first = 100, second = 200
first = 200, second = 200
Answer explanation
The code segment initializes 'first' to 100 and 'second' to 100. Therefore, after execution, the values remain unchanged. The correct answer is first = 100, second = 100.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following code segment. What are the values of first and second as a result of executing the code segment?
The value of first is true, and the value of second is true.
The value of first is true, and the value of second is false.
The value of first is false, and the value of second is true.
The value of first is false, and the value of second is false.
Answer explanation
The code segment evaluates conditions that result in both 'first' and 'second' being true. Therefore, the correct choice is that the value of first is true, and the value of second is true.
6.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
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?
x only
y only
x, y, and z
x and z only
Answer explanation
After executing the code, x is assigned the value of y (50), then y is assigned z (75), and finally z is assigned the new value of x (50). Thus, x and z both have the value 50, while y has 75.
7.
MULTIPLE CHOICE QUESTION
45 sec • 1 pt
Consider the following code segment. What is the value of r as a result of executing the code segment?
20
30
40
10
Answer explanation
The code segment likely performs a calculation that results in r being set to 20. Therefore, the correct answer is 20.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?