---
title: "AP Computer Science Principles Unit 3 Practice Test"
description: "A timed AP Computer Science Principles Unit 3 (Algorithms and Programming) practice test in the AP format, drawn from 4,403 multiple-choice questions and 120 FRQs written for the unit. The standard version takes about 64 minutes."
canonical: "https://fiveable.me/ap-comp-sci-p/unit-test/3"
type: "unit-test"
subject: "AP Computer Science Principles"
unit: "Unit 3"
---

# AP Computer Science Principles Unit 3 Practice Test

## Overview

A timed AP Computer Science Principles Unit 3 (Algorithms and Programming) practice test in the AP format, drawn from 4,403 multiple-choice questions and 120 FRQs written for the unit. The standard version takes about 64 minutes.

## Test Format

- 20 Multiple Choice Questions (34 minutes)
- 1 FRQ – Written Response 2 (30 minutes)

## Unit FRQs by Type

- [Written Response 2](/ap-comp-sci-p/frqs/written-response-2?unit=3): 120 questions

## Practice Questions

### Question 1

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) ["A", "B", "C"], containing all unique items
- (B) ["A", "B", "B", "C"], containing all items
- (C) ["B"], containing only the shared items
- (D) ["A", "C"], containing only unique items

**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 2

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?

- (A) The team can focus on displaying the data without needing to understand the sensor hardware details.
- (B) The team can modify the sensor hardware directly through the software interface to improve accuracy.
- (C) The team eliminates the need for any testing since the library procedure is guaranteed bug-free.
- (D) The team reduces the application's file size by removing the need for any temperature-related code.

**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 3

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?

- (A) The fix propagates to all parts of the program that call the procedure without further changes.
- (B) The team must manually update every line of code where the procedure was originally copied.
- (C) The team must rename the procedure to ensure the program recognizes the updated version.
- (D) The team must rewrite the inputs for every call to the procedure to match the new logic.

**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 4

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?

- (A) They only need to write and debug the character drawing logic once for all three projects.
- (B) They ensure that the games will look exactly the same regardless of the parameters passed.
- (C) They eliminate the need for parameters by hardcoding the character's position in the code.
- (D) They prevent the games from running on different operating systems by linking them together.

**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 5

A group of students is simulating a city. They create a `Car` class (abstraction) with methods like `drive()` and `park()`. How does this abstraction help the group manage the complexity of the simulation?

- (A) It allows the group to treat each car as a single object rather than tracking variables separately.
- (B) It eliminates the need to use variables for the car's speed and location within the simulation.
- (C) It ensures that the simulation runs in constant time regardless of the number of cars added.
- (D) It prevents the students from modifying the behavior of the cars once the class is defined.

**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 6

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?

- (A) It simplifies the code by hiding the low-level graphics and event-handling details.
- (B) It prevents the team from customizing the button's color or size to ensure consistency.
- (C) It increases the complexity of the program by adding unnecessary library dependencies.
- (D) It ensures that the button cannot be clicked more than once by the user of the program.

**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 7

Two teams are merging their code. Team A uses a procedure `getData()` written by Team B. Team A does not know how `getData()` works internally. Which concept best describes this interaction?

- (A) Procedural abstraction, which separates the use of a function from its implementation.
- (B) Data compression, which reduces the size of the code being shared between the two teams.
- (C) Symmetric encryption, which protects the internal code from being viewed by the other team.
- (D) Lossless compression, which ensures no data is lost when the teams merge their files.

**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.

### Question 8

A team of programmers is developing a mobile application. One programmer suggests using a pre-existing external library for handling GPS location data instead of writing new code. Which of the following best explains how this abstraction manages the complexity of the project?

- (A) It reduces the amount of new code the team must write and test by reusing verified solutions.
- (B) It increases the program's execution speed by removing the need for location data processing.
- (C) It ensures the application will work on all hardware devices without any additional configuration.
- (D) It eliminates the need for the team to understand high-level logic regarding user location privacy.

**Answer: (A)** Linking the use of libraries to reduced workload and reliability.

### Question 9

A large software team notices that the code to calculate sales tax is repeated in multiple files. A developer refactors this code into a single procedure named `calculateTax`. How does this abstraction manage complexity for the group during future maintenance?

- (A) It localizes updates so that a change to the tax rate needs to be made in only one place.
- (B) It improves the runtime efficiency of the program by executing the tax calculation fewer times.
- (C) It automatically corrects logical errors in the tax calculation without human intervention.
- (D) It prevents other developers from calling the tax calculation code from unauthorized modules.

**Answer: (A)** Identifying localization of change as a primary benefit of procedural abstraction.

### Question 10

A team chooses to write a web application using a high-level programming language rather than a low-level assembly language. How does this choice of abstraction primarily help the group manage the complexity of development?

- (A) It provides readable syntax that allows team members to understand logic closer to human language.
- (B) It allows the team to access and manipulate the computer's memory addresses directly and precisely.
- (C) It eliminates the need for the team to use a compiler or interpreter to execute the final program.
- (D) It ensures the application will run with identical performance regardless of the underlying hardware.

**Answer: (A)** Linking high-level languages to improved readability and cognitive management.

## Review the Unit

- [3.1 Variables and Assignments](/ap-comp-sci-p/unit-3/variables-assignments/study-guide/vtJhAf5XFOkm1uHNDMvh)
- [3.2 Data Abstraction](/ap-comp-sci-p/unit-3/data-abstraction/study-guide/kMMTClSiHohfiaHMGFFE)
- [3.3 Mathematical Expressions](/ap-comp-sci-p/unit-3/mathematical-expressions/study-guide/00lGBdF7QyY5hmd1rubD)
- [3.4 Strings](/ap-comp-sci-p/unit-3/strings/study-guide/0bMtDyDHxqMcwyDgQkjw)
- [3.5 Boolean Expressions](/ap-comp-sci-p/unit-3/boolean-expressions/study-guide/LkLTi80KQM04AnmNBxCq)
- [3.6 Conditionals](/ap-comp-sci-p/unit-3/conditionals/study-guide/JAgsZEPFqWJchRBqrX1O)
- [3.7 Nested Conditionals](/ap-comp-sci-p/unit-3/nested-conditionals/study-guide/iM5nw43cqaIowgYhEjyD)
- [3.8 Iteration](/ap-comp-sci-p/unit-3/iteration/study-guide/7megnIMaNHzDdrVKT9mR)
- [3.9 Developing Algorithms](/ap-comp-sci-p/unit-3/developing-algorithms/study-guide/eFTUAVlAEU4XUX3MeQmF)
- [3.10 Lists](/ap-comp-sci-p/unit-3/lists/study-guide/mCE6meIGp5pqs1y5ym3h)
- [3.11 Binary Search](/ap-comp-sci-p/unit-3/binary-search/study-guide/YADShVFQZbqwGicqH3ub)
- [3.12 Calling Procedures](/ap-comp-sci-p/unit-3/calling-procedures/study-guide/lwdr3yhVOtUJZhAmJ5cu)
- [3.13 Developing Procedures](/ap-comp-sci-p/unit-3/developing-procedures/study-guide/Jhzac68HzbAilXRPuZFJ)
- [3.14 Libraries](/ap-comp-sci-p/unit-3/libraries/study-guide/yO78dFsy00yf4OssUKTl)
- [3.15 Random Values](/ap-comp-sci-p/unit-3/random-values/study-guide/8SZRS3ELTeNzsvZ3E1OF)
- [3.16 Simulations](/ap-comp-sci-p/unit-3/simulations/study-guide/FbXrprMnzc77nAnIX4rw)
- [3.17 Algorithmic Efficiency](/ap-comp-sci-p/unit-3/algorithmic-efficiency/study-guide/jGSWIqW49BtrQ8dqCWFd)
- [3.18 Undecidable Problems](/ap-comp-sci-p/unit-3/undecidable-problems/study-guide/q0SSR2ddayx397Hy6ztA)
- [Big Idea 3: Algorithms and Programming](/ap-comp-sci-p/unit-3/review/study-guide/eOWMqAJUdtnmttaCSlis)

## Other Unit Tests

- [Unit 1: Creative Development](/ap-comp-sci-p/unit-test/1)
- [Unit 2: Data](/ap-comp-sci-p/unit-test/2)
- [Unit 4: Computer Systems & Networks](/ap-comp-sci-p/unit-test/4)
- [Unit 5: Impact of Computing](/ap-comp-sci-p/unit-test/5)

## About This Document

Canonical Fiveable pages are available as Markdown at the same path plus `.md`.

- [llms.txt](https://fiveable.me/llms.txt): index of Fiveable's sections and URL patterns
- [llms-full.txt](https://fiveable.me/llms-full.txt): complete subject and unit listing
- [MCP server](https://fiveable.me/mcp): call Fiveable as tools instead of fetching pages (`https://fiveable.me/api/mcp`)
- [MCP server for AP teachers](https://fiveable.me/mcp/teachers): a teacher's classes, assignments and AP-rubric grading (`https://fiveable.me/api/mcp/teacher`)
