Identifying and Correcting Errors (College Board AP® Computer Science Principles): Exam Questions

11 mins11 questions
1
1 point

A program runs to completion with no error messages, but the total it prints is always lower than it should be. What type of error is this most likely to be?

  • Syntax error

  • Logic error

  • Runtime error

  • Overflow error

2
1 point

Which statement is true of a syntax error?

  • It produces a wrong answer but lets the program run

  • It only appears while the program is running

  • It is detected before the program runs and prevents it from executing

  • It never affects whether the program runs

3
1 point

A program asks the user to type a number and then uses it in a calculation. It works normally until a user types letters instead, at which point the program stops unexpectedly partway through. What type of error is this?

  • Overflow error

  • Syntax error

  • Logic error

  • Runtime error

4
1 point

Which statement about overflow errors is correct?

  • An overflow error is a type of runtime error that occurs when a value exceeds the range that can be stored

  • An overflow error is a type of syntax error caught before the program runs

  • An overflow error happens when the code is missing a bracket

  • An overflow error occurs only in programs that have no comments

5
1 point

A developer suspects a logic error inside a loop, so they step through the code on paper, writing down the value of each variable at every line. Which error-detection method is this?

  • Using a debugger

  • Hand tracing

  • Setting a breakpoint

  • Code attribution

6
1 point

Confirming that a program's actual output matches the expected output for a given input is called:

  • Debugging

  • Validation

  • Verification

  • Attribution

7
1 point

A program passes every test that uses typical values, but after release some users still hit errors. What is the most likely reason?

  • It was developed using an iterative process

  • It contains too many comments

  • Its variable names are unclear

  • It was not tested with boundary and extreme inputs

8
1 point

An online store gives free shipping for orders of $25 or more. Which set of test inputs best checks the boundary where the free-shipping rule changes?

  • $24 and $25

  • $5 and $50

  • $10 and $40

  • $100 and $200

9
1 point

Before processing, a program checks that a date the user enters is in the format DD/MM/YYYY and rejects anything that is not. This check is an example of:

  • Verification

  • Validation

  • Debugging

  • Iteration

10
1 point

Consider the following code segment, which is intended to display each value in the list nums. What type of error, if any, occurs when the segment is executed?

nums ← [4, 8, 15]
i ← 1
REPEAT 4 TIMES
{
  DISPLAY(nums[i])
  i ← i + 1
}
  • Syntax error, because the loop keyword is used incorrectly

  • Logic error, because the loop repeats one too many times but the program still finishes

  • No error occurs; the segment displays 4, 8, and 15

  • Runtime error, because the code tries to access a list element that does not exist

11
1 point

A program reads a whole-number temperature and displays "Freezing" for values below 0, "Liquid" for values from 0 to 100 inclusive, and "Gas" for values above 100. Which set of test inputs is the most effective for checking that every output branch works correctly?

  • -1, 0, 100, 101

  • 20, 40, 60, 80

  • 50, 500

  • 0, 50, 100