AP Computer Science Principles Flashcards: Identifying and Correcting Errors
Written by AP Content Team, Verified for 2026 AP Exams, Last updated: May 2026
Review key ideas with interactive flashcards. This set includes 21 cards to help you master important concepts.
What is the purpose of 'adding extra output statement(s)' when debugging?
Adding extra output statements is an effective way to find and correct errors, often by displaying variable values at key points.
Card 1 of 21
All Flashcards (21)
What is the purpose of 'adding extra output statement(s)' when debugging?
Adding extra output statements is an effective way to find and correct errors, often by displaying variable values at key points.
What is a logic error?
A logic error is a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly.
Besides test cases and hand tracing, what are three other effective ways to find and correct errors?
Three other effective methods are using visualizations, debuggers, and adding extra output statements.
What is a run-time error?
A run-time error is a mistake in the program that occurs during the execution of a program. Programming languages define their own run-time errors.
What is the role of 'test cases' in debugging?
Test cases are an effective way to find and correct errors by using defined inputs to ensure a program produces the expected outcomes.
What kinds of inputs should be used to test a program effectively?
Defined inputs used for testing should demonstrate the different expected outcomes that are at or just beyond the extremes (minimum and maximum) of input data.
Distinguish between a logic error and a run-time error.
A logic error causes a program to behave incorrectly but continue running, while a run-time error is a mistake that typically causes the program to halt during execution.
What is the purpose of testing in the software development process?
Testing uses defined inputs to ensure that an algorithm or program is producing the expected outcomes. Programmers then use these results to revise their work.
How do programmers use the results from testing?
Programmers use the results from testing to revise their algorithms or programs.
A program attempts to access a file that does not exist and crashes. What type of error is this?
This is a run-time error because the mistake occurs during the execution of the program.
Distinguish between a syntax error and a run-time error.
A syntax error violates the language's rules and is caught before execution, while a run-time error is a mistake that only occurs during the execution of the program.
What is a syntax error?
A syntax error is a mistake in the program where the rules of the programming language are not followed.
How can a programmer check the correctness of an algorithm?
A programmer can identify inputs and their corresponding expected outputs or behaviors to check if the algorithm is correct.
What is an overflow error?
An overflow error is an error that occurs when a computer attempts to handle a number that is outside of the defined range of values.
What is the role of 'debuggers' in finding errors?
Debuggers are tools that provide an effective way for programmers to find and correct errors in their code.
List three effective ways to find and correct errors.
Three effective ways to find and correct errors are using test cases, hand tracing, and visualizations.
A programmer misspells a variable name, and the program fails to run. What kind of error is this?
This is a syntax error because a rule of the programming language (correct spelling of identifiers) was not followed.
Why are program requirements necessary for effective testing?
Program requirements are needed to identify appropriate defined inputs for testing and their corresponding expected outcomes.
If a program runs but calculates the wrong total for a list of numbers, what type of error is it?
This is a logic error because the program behaves incorrectly, leading to an unexpected output.
A program designed to work with 8-bit integers is given a calculation that results in a number larger than can be stored. What error occurs?
This is an overflow error because the computer attempted to handle a number outside of the defined range of values.
What are the two primary steps for fixing an error in an algorithm or program?
The two primary steps are to first identify the error and then to correct the error.