Skip to content
StudyFame
PreviousNext

AP CSP MCQ Practice Test 1 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 cybersecurity, Boolean expressions, variable tracing, loops, binary numbers and the Internet.

  1. 1. A user gets an email that looks like it is from their bank. It says the account is blocked and asks the user to click a link and type their password to unlock it. The email is fake. What kind of attack is this?

  2. 2. A ride allows a person only if they are at least 12 years old and their height is between 50 and 80 inches, inclusive. Which expression is true exactly when a person is allowed on the ride?

  3. 3. What is displayed when this code segment runs?

    first ← 4
    second ← 9
    temp ← first
    first ← second
    second ← temp
    first ← first + second
    DISPLAY(first)
    DISPLAY(second)
  4. 4. Which statement best describes the relationship between the Internet and the World Wide Web?

  5. 5. A program should display these seven lines, in this order: up, down, down, up, down, down, down Which code segment displays exactly this output?

    Code I
    DISPLAY("up")
    REPEAT 2 TIMES { DISPLAY("down") }
    DISPLAY("up")
    REPEAT 2 TIMES { DISPLAY("down") }
    
    Code II
    REPEAT 2 TIMES
    {
      DISPLAY("up")
      REPEAT 3 TIMES { DISPLAY("down") }
    }
    
    Code III
    REPEAT 2 TIMES
    {
      DISPLAY("up")
      DISPLAY("down")
      DISPLAY("down")
    }
    DISPLAY("down")
    
    Code IV
    DISPLAY("up")
    REPEAT 3 TIMES { DISPLAY("down") }
    DISPLAY("up")
    REPEAT 2 TIMES { DISPLAY("down") }
  6. 6. Which of these is an example of multifactor authentication (MFA) for an online bank account?

  7. 7. A game board has 10 spaces in a row, numbered 1 to 10 from left to right:

    Space: 1  2  3  4  5  6  7  8  9  10
    Color: G  R  B  B  G  Y  B  G  B  Y
    (G = green, R = red, B = black, Y = yellow)

    The piece starts on the rightmost black space and follows these rules: Yellow: move 3 spaces left. Black: move 1 space left. Green: move 2 spaces right. A counter starts at 0 and increases by 1 after every move. The game stops when the piece lands on red. What is the final value of the counter?

  8. 8. What is a direct benefit of redundant routing on the Internet?

  9. 9. How does a computer usually store an analog sound, such as a person singing?

  10. 10. A video game stores the code for its Jump button as the binary number 11010. What is this number in decimal?

  11. 11. A game uses 5-bit binary codes for its controls:

    Control     Code
    Move left   01011
    Fire        10011
    Pause       10101
    Reset       01111

    Which control has the decimal value 19?

  12. 12. A robot (R) is on the grid below, facing right. It cannot move onto a black square (#) or off the grid. G is the goal.

         col 1  2  3  4  5
    row 1    #  #  #  #  G
    row 2    .  .  #  .  .
    row 3    .  #  .  #  .
    row 4    R  .  .  .  .

    Which code segment moves the robot to the goal?

    Code I
    REPEAT UNTIL (GoalReached())
    {
      IF (CAN_MOVE("forward"))
      { MOVE_FORWARD() }
      ELSE
      { ROTATE_LEFT() }
    }
    
    Code II
    REPEAT 4 TIMES { MOVE_FORWARD() }
    ROTATE_RIGHT()
    REPEAT 3 TIMES { MOVE_FORWARD() }
    
    Code III
    ROTATE_LEFT()
    REPEAT 3 TIMES { MOVE_FORWARD() }
    ROTATE_RIGHT()
    REPEAT 4 TIMES { MOVE_FORWARD() }
    
    Code IV
    REPEAT 3 TIMES { MOVE_FORWARD() }
    ROTATE_LEFT()
    REPEAT 3 TIMES { MOVE_FORWARD() }
  13. 13. Which of the following is NOT a benefit of collaborating with others to build a computing innovation?

  14. 14. The procedure below should return true if every element of numList is greater than or equal to the element before it, and false otherwise. It does not work as intended.

    Line 1:  PROCEDURE isIncreasing(numList)
    Line 2:  {
    Line 3:    count ← 2
    Line 4:    REPEAT UNTIL (count > LENGTH(numList))
    Line 5:    {
    Line 6:      IF (numList[count] < numList[count - 1])
    Line 7:      {
    Line 8:        RETURN(true)
    Line 9:      }
    Line 10:     count ← count + 1
    Line 11:   }
    Line 12:   RETURN(false)
    Line 13: }

    Which change makes the procedure work as intended?

  15. 15. The procedure drawLine(x1, y1, x2, y2) draws a line segment from point (x1, y1) to point (x2, y2). What does this code segment draw?

    x ← 0
    REPEAT 3 TIMES
    {
      drawLine(x, 0, x, 4)
      x ← x + 2
    }