AP CSP MCQ Practice Test 2 with Answers
Each question has four options. Pick one to check your answer, or click Show answer to see the answer with an explanation. This test covers networks and fault tolerance, data compression, overflow, parallel computing, bias and tracing loops.
1. An author publishes an e-book under the Creative Commons "No Rights Reserved" (CC0) license. What does this allow other people to do?
Answer: b) Copy, share and reuse the e-book without asking the author for permissionDescription:CC0 means "No Rights Reserved". The author gives up copyright as far as the law allows, so the work becomes like public domain. People can copy, share, change and reuse it without asking, even commercially. "Non-commercial only" is a different Creative Commons license (NC).
2. In the network below, each line is a direct connection between two devices:
A – B A – C B – D D – C B – E E – F F – CWhat is the minimum number of connections that must be removed so that device B can no longer communicate with device C?
Answer: c) 3Description:Find every path from B to C:
Path 1: B → A → C Path 2: B → D → C Path 3: B → E → F → CThe three paths share no connections, so at least one connection must be cut on each path = 3. Example: remove A–B, B–D and B–E, and B is completely cut off. With only 2 removals, at least one path still works.
3. Using the same network:
A – B A – C B – D D – C B – E E – F F – CWhich statement is true?
Answer: a) If device D fails, B can still communicate with C.Description:Paths: B-A-C, B-D-C and B-E-F-C. - (a) If D fails, B-A-C and B-E-F-C still work. Correct. - (b) If A–B fails, B-D-C still works. Wrong. - (c) There are three paths, not two. Wrong. - (d) The shortest path uses 2 connections (through A or D). The path through F uses 3. Wrong. Tip: a network can have more than one path between two devices; don't look only at the shortest one.
4. How can a weak password make a user's account vulnerable to unauthorized access?
Answer: d) Attackers can guess weak passwords using lists of common passwords and repeated tries.Description:Passwords like "123456", "password" or "rahul123" appear in lists of common passwords. An attacker can use a program to try thousands of guesses very quickly (a brute-force or dictionary attack). A strong password is long, unique (different for every site) and hard to guess. Adding MFA makes the account even safer.
5. A home router limits the bandwidth available to guest users. What is the effect on guest users?
Answer: b) They can send or receive at most a fixed amount of data per second.Description:Bandwidth = how much data can be transferred per second (for example 100 Mbps). Limiting guests to, say, 10 Mbps puts an upper limit on their download and upload speed. It does not affect how many websites they can visit, encryption or routing.
6. A program stores a counter in a variable that can only hold whole numbers from −128 to 127. The counter is 127 and the program adds 1. What is the most likely result?
Answer: c) An overflow error occurs; in many systems the value wraps around to a negative number such as −128.Description:The variable is stored in a fixed number of bits (here 8), so it has a maximum value (127). Storing a bigger number causes an overflow. In many systems the value wraps around and becomes negative, for example 127 + 1 = −128. Real-life example: a view counter that suddenly shows a large negative number has overflowed.
7. Which code segment moves a robot along the same path and leaves it facing the same direction as Code 0? Assume nothing blocks the robot.
Code 0 REPEAT 2 TIMES { MOVE_FORWARD() MOVE_FORWARD() ROTATE_RIGHT() } Code 1 REPEAT 2 TIMES { ROTATE_RIGHT() MOVE_FORWARD() MOVE_FORWARD() } Code 2 count ← 0 REPEAT UNTIL (count = 4) { MOVE_FORWARD() count ← count + 1 IF (count = 2) { ROTATE_RIGHT() } } ROTATE_RIGHT() Code 3 REPEAT 4 TIMES { MOVE_FORWARD() } ROTATE_RIGHT() ROTATE_RIGHT() Code 4 count ← 0 REPEAT UNTIL (count = 4) { MOVE_FORWARD() count ← count + 1 IF (count = 1) { ROTATE_RIGHT() } } ROTATE_RIGHT()Answer: b) Code 2Description:F = MOVE_FORWARD, R = ROTATE_RIGHT. Write each code segment as a sequence of F and R:
Code 0: F F R F F R Code 1: R F F R F F (turns first, different path) Code 2: F F R F F R (same) Code 3: F F F F R R (goes straight for 4 squares) Code 4: F R F F F R (turns after the first move)In Code 2 the robot turns when count = 2, and once more after the loop, exactly like Code 0.
8. Which statement about the design of the Internet is true?
Answer: d) The Internet was designed to be scalable, so new devices and networks can be added easily.Description:The Internet is built on open protocols (TCP/IP, HTTP) and a decentralized design. Any new device or network that follows those protocols can join, so it is scalable. - No single central computer controls routing. - Not all traffic has to be encrypted (plain HTTP works without encryption). - The protocols are open, not owned by one company.
9. In which situation is lossy compression the best choice?
Answer: c) Storing songs on a phone so that more songs fit, when a small loss in quality is acceptableDescription:Lossy compression makes a file smaller by permanently removing some data (MP3, JPEG). The exact original cannot be restored. For songs, a small loss in quality is fine and more songs fit, so lossy is a good choice. For programs, bank records and documents, changing even one bit is wrong. They need lossless compression (such as ZIP).
10. What value is returned by the call mystery(5)?
PROCEDURE mystery(n) { result ← 0 j ← 1 REPEAT n TIMES { result ← result + j j ← j + 1 } RETURN(result) }Answer: b) 15Description:Trace with n = 5:
Iteration j (added) result 1 1 1 2 2 3 3 3 6 4 4 10 5 5 15The procedure returns the sum of 1 to n: n(n + 1) / 2 = 5 × 6 / 2 = 15.
11. Which situation is the biggest challenge for parallel computing?
Answer: a) Each step of a calculation needs the result of the step before it.Description:Parallel computing = several processors work on different parts of a task at the same time. It works well when the parts are independent. If step 2 needs the result of step 1, and step 3 needs step 2, the steps cannot run at the same time. They must run one after another. In the other three options each number, photo or document is independent, so parallel computing works well there.
12. A social media app is testing a new algorithm that suggests friends with similar interests. Which testing plan is LEAST likely to introduce bias?
Answer: c) Test with a random sample of all the app's usersDescription:Bias appears when the test group does not look like all the users. The algorithm then works well for one group and badly for the others. In a random sample, every kind of user (any age, city or usage level) has an equal chance of being picked, so the sample is representative. The other options pick only one kind of person (selection bias).
13. For which initial values of j and k does this code segment never stop (an infinite loop)?
REPEAT UNTIL (j = k) { j ← j + 2 } DISPLAY(j)Answer: d) j = 3, k = 8Description:Each time, 2 is added to j, so j always stays odd or always stays even.
j = 1, k = 5: 1, 3, 5 → stops j = 2, k = 8: 2, 4, 6, 8 → stops j = 4, k = 4: j = k at once → loop never runs j = 3, k = 8: 3, 5, 7, 9, 11… → never equals 8An odd j can never equal an even k, so with j = 3 and k = 8 the loop never stops.
14. What is displayed when this code segment runs?
j ← 3 k ← 4 result ← 0 REPEAT UNTIL (j > 6) { IF (j MOD 2 = 0) { result ← result + k } ELSE { result ← result + j } j ← j + 1 } DISPLAY(result)Answer: b) 16Description:When j is even, k (4) is added; when j is odd, j itself is added:
j j MOD 2 add result 3 1 (odd) 3 3 4 0 (even) 4 7 5 1 (odd) 5 12 6 0 (even) 4 16 7 loop ends (7 > 6)Displayed: 16.
15. How is a large file usually sent across the Internet?
Answer: a) It is split into packets, the packets may travel along different paths, and they are put back together at the destination.Description:This is called packet switching: 1. The file is split into small packets (each with the destination address and a sequence number). 2. Each packet can take its own path. 3. Packets may arrive out of order; the destination uses the sequence numbers to rebuild the file.