AP Computer Science Principles Practice Questions & Answers
Original foundation lessons and 12-question representative sample of a planned 48-question MCQ practice across selected goals; not complete CED coverage.. Selected foundation practice, not a complete exam simulation.
Try 10 original samples with answers below, or start a personal practice set.
Free access · No sign-up · No personal progress recorded on this page · Coverage & review notes
TRY A QUESTION. FOLLOW THE REASONING.
Sample questions with answers
Work out your answer first, then compare the explanation. This stable selection uses distinct task families across the available learning domains.
QUESTION 01Data
Reading bit patterns as values and abstractions
A game saves one high score as the byte 01010010. A separate utility later reads those same 8 bits and prints a character. Which statement correctly explains how one stored byte can support both uses?
The programs apply different interpretations to the same bits; the bit sequence alone does not fix what it represents.
Each bit carries its own data type at creation, so a byte stored as a number cannot ever be read as anything else.
Eight bits can be arranged into only 8 different patterns, so each of the two uses is assigned its own stored pattern.
The byte holds two values at once, packing the number and the character into the left and right halves.
Answer: The programs apply different interpretations to the same bits; the bit sequence alone does not fix what it represents.
Both uses read the identical stored bits, so the explanation cannot come from the storage side. What differs is the reading program: one treats the pattern as an unsigned integer, the other as a character code, and each applies its own decoding rules.
Check each alternative against the scenario: nothing retypes the bits, no second pattern is stored, and no packing is described. A bit sequence alone does not fix its meaning, which is exactly why the same 8 bits can serve both programs.
Compare the other answer choices
Each bit carries its own data type at creation, so a byte stored as a number cannot ever be read as anything else.
The scenario shows the opposite: the second program does read the byte differently. Bits are not typed at creation; interpretation is applied by whatever reads them.
Eight bits can be arranged into only 8 different patterns, so each of the two uses is assigned its own stored pattern.
Eight bits form 2^8 = 256 patterns, not 8, and the scenario stores one pattern used two ways, not one pattern per use.
The byte holds two values at once, packing the number and the character into the left and right halves.
A byte is a single sequence of 8 bits; no second value is stored, and reinterpreting the same sequence already explains both outputs.
A program sets age ← 13 and approved ← false, then runs DISPLAY(NOT (age >= 13) OR approved). What does it display?
true, because age >= 13 is true and one true part is enough for OR
false, because NOT (age >= 13) is false and false OR false is false.
true, because 13 is not strictly greater than 13
true, because NOT applies after the OR is decided and flips the combined result
Answer: false, because NOT (age >= 13) is false and false OR false is false.
Evaluate the comparison first: 13 >= 13 is true because >= includes the boundary. NOT reverses that to false. Finally false OR false evaluates to false, so the program displays false.
Re-check the grouping to see why every true option fails: NOT binds to the parenthesized comparison only, and OR combines the two already-evaluated parts. The three wrong options correspond to dropping NOT, tightening the boundary, or widening NOT over the whole OR.
Compare the other answer choices
true, because age >= 13 is true and one true part is enough for OR
This drops the NOT: the comparison does evaluate to true, but NOT reverses it to false before the OR runs, so neither part of the OR is true.
true, because 13 is not strictly greater than 13
The >= operator includes the boundary, so 13 >= 13 is true. Reading >= as strictly greater reverses the comparison and, after NOT, the whole expression.
true, because NOT applies after the OR is decided and flips the combined result
NOT is written directly before one parenthesized comparison, so its scope is that comparison only; evaluating the OR first and then negating is not how the expression is grouped.
Follow a packet from sender to reassembled message
A four-packet video clip is sent from one student’s device to another. The packets leave in order and carry addressing and sequencing information, but they arrive at the receiving device in the order 3, 1, 4, 2. What does the receiving device do to produce the complete clip?
It plays the pieces in arrival order, because that arrival order reflects the routes the packets actually took across the networks.
It asks the sender to resend all four packets along one fixed route so the copies arrive in order.
It restores the original order using each packet’s sequencing information, then reassembles the clip from the ordered pieces.
It waits for the network’s last router to reassemble the clip into one finished stream before delivering it.
Answer: It restores the original order using each packet’s sequencing information, then reassembles the clip from the ordered pieces.
The receiving device reads each packet’s sequencing information and restores the original order 1, 2, 3, 4 before reassembly. The arrival order 3, 1, 4, 2 reflects the different routes the packets took, not the message’s structure.
The distractor procedures all act at the wrong place or on the wrong evidence: arrival order (routes, not content), resending on one route (unnecessary and contrary to independent paths), or reassembly in a router (ordering information travels for the destination’s use). The stated packet design decides the procedure.
Compare the other answer choices
It plays the pieces in arrival order, because that arrival order reflects the routes the packets actually took across the networks.
Arrival order follows the routes taken, not the order the packets left in; playing 3, 1, 4, 2 would present the clip out of sequence instead of restoring it.
It asks the sender to resend all four packets along one fixed route so the copies arrive in order.
The data has already arrived intact. Sequencing information lets the receiving device restore the order locally, so resending on a single route is unnecessary and contradicts the independent-path behavior described.
It waits for the network’s last router to reassemble the clip into one finished stream before delivering it.
Reassembly happens at the destination device, which is why the packets carry sequencing information; intermediate routers forward packets and do not rebuild messages.
A program sets vals ← [3, 7, 2, 9, 5] and i ← 2, then runs DISPLAY(vals[i + 2]). What does it display?
7, the element sitting at index i
An index error, because an arithmetic expression cannot be used as a list index
9
5, the element in the fifth slot
Answer: 9
Compute the index first: i + 2 = 4. Lists are indexed from 1, so vals[4] is the fourth element of [3, 7, 2, 9, 5], which is 9. The index is valid because 4 is between 1 and LENGTH(vals) = 5.
The two numeric alternatives come from skipping the addition or counting slots from 0, and the error option misstates when the index rule applies. All three contradict the 1-based indexing convention, under which the n-th element sits at index n with no offset.
Compare the other answer choices
7, the element sitting at index i
The display reads vals[i + 2], so the index must be computed before the access; stopping at vals[2] skips the addition the expression states.
An index error, because an arithmetic expression cannot be used as a list index
A computed expression is a normal way to form an index; the error applies only when the resulting index is below 1 or above the list length, and 4 is inside 1 through 5.
5, the element in the fifth slot
This counts index 4 as the fifth element, as if indexing started at 0. The first element is at index 1, so index 4 is the fourth element.
A sensor package logs the unsigned binary value 101011. What decimal value does it represent?
53
86
43
15
Answer: 43
Label each place from the right as 1, 2, 4, 8, 16, 32. The 1-bits sit in the 32, 8, 2 and 1 places, so the value is 32 + 8 + 2 + 1 = 43.
Verify by converting back: 43 - 32 = 11, 11 - 8 = 3, 3 - 2 = 1, 1 - 1 = 0, which lights exactly the bits of 101011. Each wrong option shifts, reverses, or replaces the place row, changing which powers of two enter the sum.
Compare the other answer choices
15
This adds the printed positions of the 1-bits, the 1st, 3rd, 5th and 6th from the left, instead of their place values. A digit contributes its place value (32, 8, 2 or 1 here), not its position number.
53
This reverses the place-value direction, reading 101011 as if places grew from the left (1, 2, 4, 8, 16, 32), which gives 1 + 4 + 16 + 32. Place values grow right to left starting at 1, so the 8s and 2s places are misassigned.
86
This starts the place row at 2 instead of 1, giving 64 + 16 + 4 + 2. The rightmost place is 2^0 = 1, so this reading drops the 1s place and shifts every other place up.
An arcade cabinet stores each score in a fixed 8-bit unsigned integer. A score reaches the largest value the 8 bits can hold, and the player then earns one more point. Which outcome follows from the fixed number of bits?
Eight bits still represent 256 distinct patterns, so the new score of 256 remains representable within them.
The score stays at its maximum and the extra point is dropped without any error or indication appearing.
The stored bit pattern rotates, so the score wraps around to a low value near zero, as some languages handle values beyond their range.
The value 256 is outside the 0-255 range the fixed 8 bits can name, so the score no longer fits: an overflow error occurs.
Answer: The value 256 is outside the 0-255 range the fixed 8 bits can name, so the score no longer fits: an overflow error occurs.
Eight bits form 2^8 = 256 patterns, and as unsigned integers those patterns name 0 through 2^8 - 1 = 255. The value 256 would need a 257th pattern, so it exceeds what the allotted bits can represent.
That failure is overflow: a computed value exceeds the maximum for the allotted bits. The stem fixes the width at 8 bits, so the options that keep the value playable, by clamping or wrapping, describe program choices outside the stated representation rule.
Compare the other answer choices
Eight bits still represent 256 distinct patterns, so the new score of 256 remains representable within them.
256 counts the patterns; as unsigned values those patterns name 0 through 255. A value of 256 is not one of the 256 patterns, so it is not representable in 8 bits.
The score stays at its maximum and the extra point is dropped without any error or indication appearing.
Stopping at the maximum is a clamping choice some programs make, but the fixed-bit limit itself does not produce it; the described failure of a value exceeding its allotted bits is overflow.
The stored bit pattern rotates, so the score wraps around to a low value near zero, as some languages handle values beyond their range.
Wraparound is an implementation behavior of particular languages, not something the stem establishes; what the stem establishes is that 256 exceeds the range the fixed 8 bits can name, and the course names that failure an overflow error.
A weather panel runs IF(temp > 30) { DISPLAY("Hot") } ELSE { IF(temp > 20) { DISPLAY("Mild") } ELSE { DISPLAY("Cool") } } with temp ← 28. Which output does it produce?
Nothing, because the first condition is false and an IF block runs no statements when its condition is false.
Hot, because 28 is a high temperature
Hot and then Mild, because both comparisons involving 28 can succeed in one pass
Mild
Answer: Mild
The outer condition temp > 30 is false at 28, so control passes into the ELSE block. The nested condition temp > 20 is true at 28, so the nested IF runs DISPLAY("Mild") and the nested ELSE is skipped.
Trace one decision at a time: the outer IF/ELSE chose the ELSE subtree, and inside it the nested IF/ELSE chose Mild. The failed outer test neither skipped the construct (an ELSE exists) nor allowed a second display.
Compare the other answer choices
Nothing, because the first condition is false and an IF block runs no statements when its condition is false.
A plain IF without ELSE does take no action, but this IF has an ELSE. The ELSE block runs when the outer condition is false, and inside it temp > 20 is true, so Mild displays.
Hot, because 28 is a high temperature
Whether 28 feels warm is not the test; the outer comparison is temp > 30, which is false at 28, so the Hot block never runs.
Hot and then Mild, because both comparisons involving 28 can succeed in one pass
Each IF/ELSE decision selects exactly one branch. Here the outer test fails, the nested test succeeds, and exactly one DISPLAY runs.
A festival app runs IF(points >= 100) { DISPLAY("access") } followed by IF(points > 100) { DISPLAY("bonus") } ELSE { DISPLAY("standard") }, with points ← 100. Which output does the app produce?
access, then standard
access and then bonus
standard, with no access line
access, and nothing else
Answer: access, then standard
Test each statement in order. 100 >= 100 is true because >= includes the boundary, so access displays. Then 100 > 100 is false because > excludes the boundary, so the second statement takes its ELSE branch and standard displays.
The two operators differ exactly at the boundary value: >= accepts 100, > rejects it. Nothing skips the second statement, so both outputs appear, one from each selection.
Compare the other answer choices
access and then bonus
This reads > as including the boundary. The bonus branch requires points > 100, which is false at exactly 100, so bonus never displays.
standard, with no access line
This reads >= as excluding the boundary, which would make the first test false. In this pseudocode 100 >= 100 is true, so access displays before the second test runs.
access, and nothing else
The two IF statements are evaluated independently. After access displays, the second comparison is still tested, and its false result sends control to the ELSE.
A program runs queue ← [10, 20, 30, 40], then INSERT(queue, 2, 15), then REMOVE(queue, 3), then APPEND(queue, 50). What is queue afterward?
[10, 15, 40, 50]
[10, 15, 30, 40, 50]
[10, 20, 40, 15, 50]
[10, 15, 20, 40, 50]
Answer: [10, 15, 30, 40, 50]
Apply one operation at a time to the index row. INSERT(queue, 2, 15) shifts 20, 30, 40 right and gives [10, 15, 20, 30, 40]. REMOVE(queue, 3) deletes the value at index 3, which is now 20, and shifts the tail left: [10, 15, 30, 40]. APPEND(queue, 50) adds 50 at the end: [10, 15, 30, 40, 50].
Each wrong option breaks exactly one step: replacing instead of shifting, appending instead of inserting at index 2, or reordering the statements. Tracking the length after each step, 5 then 4 then 5, catches the replace and append errors immediately.
Compare the other answer choices
[10, 15, 40, 50]
This treats INSERT as replacing the element at index 2. INSERT shifts elements at indices >= 2 one position right instead, so 20 survives and is what REMOVE(queue, 3) later deletes.
[10, 20, 40, 15, 50]
This appends 15 to the end instead of placing it at index 2, which moves the eventual removal to 30. INSERT places the value at the specified index and shifts the rest right.
[10, 15, 20, 40, 50]
This performs REMOVE before INSERT. The statements run in the written order: after the insert, index 3 holds 20, so REMOVE(queue, 3) deletes 20, not 30.
A program sets vals ← [3, 8, 2, 6] and total ← 0, then runs FOR EACH v IN vals { IF(v >= 3) { total ← total + v } ELSE { total ← total + 1 } }, then DISPLAY(total). What does it display?
19, the sum of every element in vals
16, reading the >= test as strictly greater
17, adding only the elements that pass the test
18
Answer: 18
FOR EACH visits 3, 8, 2, 6 in order, one pass each. Passes: 3 >= 3 adds 3; 8 >= 3 adds 8; 2 fails the test, so the ELSE adds 1; 6 >= 3 adds 6. total = 3 + 8 + 1 + 6 = 18.
Each pass runs exactly one branch, and the ELSE pass contributes 1 rather than v. The three wrong totals come from adding v unconditionally, tightening >= to >, or dropping the ELSE pass altogether.
Compare the other answer choices
19, the sum of every element in vals
This adds v on every pass, including the pass where v = 2. That pass fails the IF and runs the ELSE branch, which adds 1 instead of 2.
16, reading the >= test as strictly greater
With a strict reading, v = 3 fails the test and the ELSE adds 1 instead of 3. The >= operator includes 3, so that pass adds 3.
17, adding only the elements that pass the test
This skips the ELSE branch entirely, but the pass where v = 2 still runs and its ELSE adds 1 to total.
Original foundation lessons and 12-question representative sample of a planned 48-question MCQ practice across selected goals; not complete CED coverage.
Study selected computer-science principles, trace original pseudocode scenarios, and explain how data, programs and networks behave.
Four-option, one-answer foundation practice. The official end-of-course exam also includes multiple-select items, reading-passage items and written responses; this is not an AP score predictor.
10 public examples12 question variants in the studio12 task families
Review status: Independent educator review and learner calibration are pending. Use these selected foundation examples alongside the coverage map and current official references.
Start with the lesson linked to an unfamiliar topic, try a focused set in the practice studio, then return to the review cards. Your practice progress stays in this browser.
Catalog scope record: . This records the saved content mapping, not a guarantee that every external rule is current.
Original foundation lessons and 12-question representative sample of a planned 48-question MCQ practice across selected goals; not complete CED coverage.
No full-length AP mock, automated Create-performance-task scoring, calibrated difficulty or official score prediction.
Practice items are original text scenarios; no official exam items, figures or reference-sheet pages are reproduced, and the reading-passage and multiple-select formats are not simulated.
Check the exam provider's current information for registration, test rules and official preparation materials. The exam guide collects the relevant official references.