AP Computer Science Principles Practice Quiz: Identifying and Correcting Errors
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Test your understanding with short quizzes. This quiz has 16 questions to check your progress.
Question 1 of 16
All Questions (16)
A) Logic error
B) Syntax error
C) Run-time error
D) Overflow error
Correct Answer: B
According to the provided content, a syntax error is a mistake where the rules of the programming language are not followed. Forgetting a required semicolon is a direct violation of language rules.
A) Logic error
B) Syntax error
C) Run-time error
D) Overflow error
Correct Answer: A
The content defines a logic error as a mistake in the algorithm that causes it to behave incorrectly or unexpectedly. The program runs, but the faulty algorithm produces an incorrect result, which is a classic logic error.
A) 25, 50, 75
B) 0, 120, 121
C) A negative number, a letter, a symbol
D) 10, 20, 30
Correct Answer: B
The content states that defined inputs should demonstrate outcomes 'at or just beyond the extremes (minimum and maximum) of input data.' The inputs 0 (minimum), 120 (maximum), and 121 (just beyond the maximum) best fit this requirement.
A) Hand tracing
B) Using a debugger
C) Adding extra output statement(s)
D) Using visualizations
Correct Answer: C
The provided content lists 'adding extra output statement(s)' as an effective way to find and correct errors. Displaying a variable's value with a print statement is a direct example of this technique.
A) Logic error
B) Syntax error
C) Run-time error
D) Overflow error
Correct Answer: C
The content defines a run-time error as 'a mistake in the program that occurs during the execution of a program.' Since the error happened while the program was running, it is a run-time error.
A) Overflow error
B) Syntax error
C) Run-time error
D) Logic error
Correct Answer: A
An overflow error is defined as an error that 'occurs when a computer attempts to handle a number that is outside of the defined range of values.' This scenario perfectly matches the definition.
A) The programming language's run-time errors
B) The program requirements
C) The most common syntax errors
D) How to use a debugger
Correct Answer: B
The content explicitly states that 'Program requirements are needed to identify appropriate defined inputs for testing.' Without knowing the requirements, a programmer cannot determine what the expected outcomes or extreme values are.
A) To find every possible bug in the program
B) To ensure the program follows the language's syntax rules
C) To use defined inputs to ensure the program produces expected outcomes
D) To check for overflow errors exclusively
Correct Answer: C
The text states, 'In the development process, testing uses defined inputs to ensure that an algorithm or program is producing the expected outcomes.' This is the primary purpose of testing.
A) Using a debugger
B) Using visualizations
C) Adding output statements
D) Hand tracing
Correct Answer: D
The provided content lists 'hand tracing' as an effective way to find and correct errors. This process involves manually stepping through the code and tracking variables, which is exactly what the programmer is doing.
A) 9
B) 10
C) 11
D) 0
Correct Answer: B
The content emphasizes testing at the 'extremes (minimum and maximum) of input data.' In this case, 10 is the minimum value for the expected outcome (getting a discount). Testing with the input 10 would reveal that the program is behaving incorrectly at this boundary condition.
A) Test cases
B) Hand tracing
C) Asking another programmer for help
D) Debuggers
Correct Answer: C
The content lists the following effective ways: 'test cases, hand tracing, visualizations, debuggers, adding extra output statement(s)'. Asking another programmer for help is not on this specific list.
A) Release the program as is
B) Delete the failing test cases
C) Use the results to revise the algorithm or program
D) Assume the computer has a hardware fault
Correct Answer: C
The text states, 'Programmers use the results from testing to revise their algorithms or programs.' This indicates that identifying an error through testing should lead to correcting it.
A) Check the correctness of an algorithm or program
B) Choose a programming language
C) Prevent all run-time errors
D) Write the initial program requirements
Correct Answer: A
Point 2 of the provided content states that this process is used to 'check the correctness of an algorithm or program.' This is the fundamental basis of testing.
A) Syntax error because the program failed
B) Run-time error triggered by a specific input value
C) Logic error because the algorithm is flawed for all inputs
D) Overflow error because zero is outside the range
Correct Answer: B
The error occurs 'during the execution of a program,' which fits the definition of a run-time error. It is not a syntax error because the program started running. While it stems from a flaw in logic, its manifestation as a crash during execution makes 'run-time error' the most precise classification based on the provided definitions.
A) Test the program and then document the results
B) Write the code and then compile it
C) Identify the error and then correct the error
D) Define the inputs and then define the outputs
Correct Answer: C
Point 1 of the content explicitly lists the two steps for handling errors in an algorithm or program as: 'a. Identify the error. b. Correct the error.'
A) Syntax error
B) Run-time error
C) Compilation error
D) Logic error
Correct Answer: D
The content defines a logic error as 'a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly.' This is distinct from a syntax error, which violates language rules, and a run-time error, which causes a crash during execution.