AP® practice test

Free AP® Computer Science Principles Practice Test (2026)

This is a set of 25 original practice questions that follow the official AP® Computer Science Principles course outline and its big-idea weights, each with a short explanation. Code questions use the pseudocode of the exam reference sheet, where list indexes start at 1.

  • 25 questions
  • 5 topics from the official outline
  • No timer
Start the test

Free. Create a free account to see your score.

The practice test

25 questions

Question 1 of 25Consider the following code segment. x ← 3 y ← 7 x ← x + y y ← x - y x ← x - y DISPLAY(x) DISPLAY(y) What is displayed?
Question 2 of 25What is the decimal (base 10) value of the binary number 110101?
Question 3 of 25A student connects to a free wireless network named "Library_Guest" in a library. The network was actually set up by an attacker sitting nearby, who can now see the traffic of anyone who joins it. What is the attacker's device?
Question 4 of 25Consider the following code segment. nums ← [4, 1, 6, 3, 8] total ← 0 FOR EACH n IN nums { IF(n MOD 2 = 0) { total ← total + n } } DISPLAY(total) What is displayed?
Question 5 of 25A program is supposed to display the larger of two numbers that the user enters. It runs to the end without stopping for every input, but it always displays the smaller number. What kind of error does the program contain?
Question 6 of 25A small network has these direct connections: A–B, A–C, B–C, B–D, C–D, D–E and E–F. Which single connection, if it stopped working, would leave device A unable to communicate with device F?
Question 7 of 25Each item in a warehouse must get its own unique code, made of a fixed number of bits. There are 200 different items. What is the smallest number of bits per code that gives every item a unique code?
Question 8 of 25Consider the following code segment. count ← 0 n ← 50 REPEAT UNTIL(n < 5) { n ← n / 2 count ← count + 1 } DISPLAY(count) What is displayed?
Question 9 of 25Maria has a public key and a matching private key. Jon wants to send Maria a message that only Maria can read, using public key encryption. Which key should Jon use to encrypt the message?
Question 10 of 25Consider the following code segment. letters ← ["a", "b", "c", "d"] REMOVE(letters, 2) INSERT(letters, 2, "x") APPEND(letters, "b") DISPLAY(letters[3]) What is displayed?
Question 11 of 25A hospital stores medical scans and must be able to rebuild every scan exactly as it was recorded, pixel for pixel. Which approach should it use to reduce the storage space the scans need?
Question 12 of 25Which of the following logins uses multifactor authentication?
Question 13 of 25A team builds a game by writing one small part, testing it until it works, and only then adding the next part to the whole program. Which development approach does this describe?
Question 14 of 25Which of the following expressions is true exactly when the number x is between 10 and 20, including 10 and 20?
Question 15 of 25Four independent tasks take 40, 30, 20 and 10 seconds to run. The tasks are split between two processors that run at the same time, and each task runs on only one processor. What is the shortest possible total time to finish all four tasks?
Question 16 of 25Which of the following is metadata about a digital photo, rather than the photo's data?
Question 17 of 25A city wants to reduce the digital divide. Which of the following actions most directly addresses it?
Question 18 of 25A program needs to search a long list of names using binary search instead of linear search. What must be true of the list for binary search to work correctly?
Question 19 of 25A procedure is meant to return "pass" when a score is 60 or higher and "fail" otherwise. Which set of test scores is best for checking the boundary of this condition?
Question 20 of 25A delivery company wants the shortest route through 60 stops, but checking every possible route would take far too long. It uses a method that quickly finds a route that is good but not always the best. What is this method called?
Question 21 of 25A survey asked people to type the name of their home state, and the answers include "CA", "Calif." and "california" for the same state. What should be done before counting answers by state?
Question 22 of 25A company trains a program to rank job applicants using its records of whom it hired over the past 20 years. Which of the following is the most likely risk?
Question 23 of 25Data sent over the internet is broken into packets, which may take different routes and arrive out of order or not at all. Which protocol puts the packets back in order and asks for missing ones to be sent again?
Question 24 of 25A game should simulate an event that happens 30% of the time. Which of the following conditions is true about 30% of the time? (RANDOM(a, b) returns a random integer from a to b, inclusive, with each value equally likely.)
Question 25 of 25Thousands of volunteers use their own computers to sort telescope images of galaxies into types for astronomers. What is this an example of?

Your answers save on this device as you go.

Not sure where to start?

Ask Iris, our AI assistant, which exams your college takes and which guide fits. A person on our team answers at team@transfercredit.org.

These are practice questions we wrote from the official outline. This is not the real exam, and a practice score doesn't predict your AP score. We source all of this information from College Board. Each college decides whether to award credit for an AP exam, so confirm with your registrar before you book an exam. AP® is a registered trademark of the College Board, which was not involved in making these questions and does not endorse TransferCredit.org. Terms