AP Computer Science Principles Unit 3 practice questions
Try 10 multiple-choice questions from Unit 3 here. Pick an answer to see why it's right or wrong, then take the timed test above for a full AP-style set.
Question 1
A variable
limitis set to decimal 50. A sensor variablereadingupdates with binary values. Which binaryreadingvalue causes the conditionreading > limitto be true?00110011, representing decimal value 51
00110001, representing decimal value 49
00110010, representing decimal value 50
00101111, representing decimal value 47
Show answer
Answer: (A)
Converting the binary value () results in decimal 51, which is the only option strictly greater than the threshold of 50.
Question 2
A programmer merges two lists of user IDs, group1 and group2, ensuring no duplicates appear in the final list. The code segment is:
group1 = ["A", "B"] group2 = ["B", "C"] final = [] FOR EACH g IN group1 APPEND(final, g) FOR EACH g IN group2 IF NOT (g IN final) APPEND(final, g)
What is the content of the list final after the code executes?
["A", "B", "C"], containing all unique items
["A", "B", "B", "C"], containing all items
["B"], containing only the shared items
["A", "C"], containing only unique items
Show answer
Answer: (A)
Tracing the execution shows that "A" and "B" are added first. When processing group2, "B" is skipped because it is already in the list, and "C" is added. This results in a union of the two lists without duplicates.
Question 3
A team of four students is creating a mobile app. They decide to create a separate procedure for each major feature (e.g., login, updateDatabase, displayMap). How does this use of abstraction best support their collaboration?
It allows each student to develop and test their assigned procedure independently.
It requires all students to understand the internal logic of every procedure.
It ensures that all students must edit the same lines of code simultaneously.
It prevents the students from sharing any variables between the different parts.
Show answer
Answer: (A)
Recognizing how modular abstraction enables parallel development is key. By defining procedures, students can work on the internal logic of their assigned parts without interfering with others, as long as the interface remains consistent.
Question 4
A group of developers uses a shared procedure
calculateTax(amount)in an e-commerce program. One developer optimizes the internal math of the procedure without changing its name or parameters. How does this abstraction manage complexity for the rest of the group?The other developers can continue using the procedure without modifying their own code.
The other developers must update their code to match the new internal variable names.
The other developers must rewrite the procedure calls to include the new logic explicitly.
The other developers are prevented from using the procedure until they review the logic.
Show answer
Answer: (A)
Connecting abstraction to code maintenance reveals that as long as the interface (parameters/name) stays the same, internal changes do not break dependent code.
Question 5
A software team is building a weather application. Instead of writing code to measure temperature data from raw sensors, they use a pre-written library procedure
getTemperature(). Which statement best explains how this abstraction manages complexity?The team can focus on displaying the data without needing to understand the sensor hardware details.
The team can modify the sensor hardware directly through the software interface to improve accuracy.
The team eliminates the need for any testing since the library procedure is guaranteed bug-free.
The team reduces the application's file size by removing the need for any temperature-related code.
Show answer
Answer: (A)
Identifying the reduction of cognitive load is central to abstraction. The library hides the low-level hardware complexity, allowing the team to focus on high-level application logic.
Question 6
A development team identifies a bug in a frequently used procedure
processPayment(). After fixing the bug inside the procedure, how does the use of abstraction affect the rest of the team's code?The fix propagates to all parts of the program that call the procedure without further changes.
The team must manually update every line of code where the procedure was originally copied.
The team must rename the procedure to ensure the program recognizes the updated version.
The team must rewrite the inputs for every call to the procedure to match the new logic.
Show answer
Answer: (A)
Identifying the maintenance benefit of abstraction is key. Because the logic is centralized in one abstraction, a single fix corrects the behavior everywhere it is used.
Question 7
A team is building a suite of three different games. They create a shared
drawCharacter()procedure used in all three games. How does this abstraction reduce the complexity of their collaborative work?They only need to write and debug the character drawing logic once for all three projects.
They ensure that the games will look exactly the same regardless of the parameters passed.
They eliminate the need for parameters by hardcoding the character's position in the code.
They prevent the games from running on different operating systems by linking them together.
Show answer
Answer: (A)
Connecting code reuse to complexity management is the goal. Abstraction allows a solution to be defined once and reused across multiple contexts.
Question 8
A group of students is simulating a city. They create a
Carclass (abstraction) with methods likedrive()andpark(). How does this abstraction help the group manage the complexity of the simulation?It allows the group to treat each car as a single object rather than tracking variables separately.
It eliminates the need to use variables for the car's speed and location within the simulation.
It ensures that the simulation runs in constant time regardless of the number of cars added.
It prevents the students from modifying the behavior of the cars once the class is defined.
Show answer
Answer: (A)
Recognizing encapsulation is key. The class abstraction bundles related data and behaviors, allowing the group to think at a higher level (cars) rather than a lower level (coordinates/speed).
Question 9
A team is designing a user interface. They use a standard library procedure
createButton()instead of writing code to draw pixels and detect clicks. What is the primary benefit of this abstraction for the team?It simplifies the code by hiding the low-level graphics and event-handling details.
It prevents the team from customizing the button's color or size to ensure consistency.
It increases the complexity of the program by adding unnecessary library dependencies.
It ensures that the button cannot be clicked more than once by the user of the program.
Show answer
Answer: (A)
Identifying the hiding of detail is the core of abstraction. The team uses the high-level concept (button) without managing the complex low-level implementation.
Question 10
Two teams are merging their code. Team A uses a procedure
getData()written by Team B. Team A does not know howgetData()works internally. Which concept best describes this interaction?Procedural abstraction, which separates the use of a function from its implementation.
Data compression, which reduces the size of the code being shared between the two teams.
Symmetric encryption, which protects the internal code from being viewed by the other team.
Lossless compression, which ensures no data is lost when the teams merge their files.
Show answer
Answer: (A)
Defining the concept accurately is required. Procedural abstraction allows one team to use another's code based solely on what it does, not how it does it.
What's on the AP Computer Science Principles Unit 3 practice test
The standard version takes about 64 minutes and follows the timing and directions of the AP exam, sized to one unit:
- 20 Multiple Choice Questions (34 minutes)
- 1 FRQ – Written Response 2 (30 minutes)
Questions are drawn from 4229 multiple-choice questions and 120 FRQs written for Unit 3, Algorithms and Programming.
Practice AP Computer Science Principles Unit 3 FRQs
Answer the unit's free-response questions one at a time and get a score on every part.
- Written Response 2 (120 questions)
Review Unit 3 before you start
- 3.1 Variables and Assignments
- 3.2 Data Abstraction
- 3.3 Mathematical Expressions
- 3.4 Strings
- 3.5 Boolean Expressions
- 3.6 Conditionals
- 3.7 Nested Conditionals
- 3.8 Iteration
- 3.9 Developing Algorithms
- 3.10 Lists
- 3.11 Binary Search
- 3.12 Calling Procedures
- 3.13 Developing Procedures
- 3.14 Libraries
- 3.15 Random Values
- 3.16 Simulations
- 3.17 Algorithmic Efficiency
- 3.18 Undecidable Problems
- Big Idea 3: Algorithms and Programming