Run-time error in AP Computer Science Principles

In AP Computer Science Principles, a run-time error is a mistake in a program that occurs during the execution of the program, such as dividing by zero. Each programming language defines its own run-time errors, and the program may crash or stop when one happens (EK CRD-2.I.3).

Verified for the 2027 AP Computer Science Principles examLast updated June 2026

What is run-time error?

A run-time error is a mistake that doesn't show up until the program is actually running. The code is written correctly enough to start executing, but something goes wrong mid-run. Classic example: your program divides a number by a user's input, and the user types 0. The code looked fine, but the moment that division executes, the program crashes.

The key word is when. A syntax error stops you before the program ever runs because you broke the language's rules. A run-time error waits until execution to bite you. The CED also notes that programming languages define their own run-time errors, so what crashes a Python program might be handled differently in JavaScript. Many run-time errors depend on input, which is exactly why testing with inputs at or beyond the extremes (EK CRD-2.J.2) is how you catch them before the user does.

Why run-time error matters in AP® Computer Science Principles

Run-time errors live in Topic 1.4 (Identifying and Correcting Errors) in Unit 1: Creative Development. Learning objective AP Comp Sci P 1.4.A asks you to identify an error and correct it, and to do that you need to classify it first. The CED defines four error types side by side: logic, syntax, run-time, and overflow (EK CRD-2.I.1 through CRD-2.I.4). The exam loves giving you a buggy scenario and asking which type of error it is. Run-time errors also connect directly to 1.4.B and testing, because the whole point of testing with defined inputs is to flush out the errors that only appear during execution.

How run-time error connects across the course

Syntax error (Unit 1)

Syntax errors and run-time errors are separated by timing. A syntax error breaks the language's rules and prevents the program from running at all. A run-time error happens only once the program is executing. If the program never started, it's not a run-time error.

Logic error (Unit 1)

A logic error doesn't crash anything. The program runs to completion but produces wrong or unexpected results because the algorithm itself is flawed. Run-time errors are loud (the program stops); logic errors are quiet (the program lies to you).

Overflow error (Unit 1)

An overflow error happens when a computer tries to handle a number outside its defined range of values (EK CRD-2.I.4). It's really a specific flavor of execution-time failure, so MCQs sometimes put it next to run-time error to see if you know the precise definitions.

Testing with defined inputs (Unit 1, Topic 1.4)

EK CRD-2.J.2 says to test inputs at or just beyond the extremes (minimum and maximum). That's run-time error hunting. Inputs like 0, negative numbers, or empty values are exactly the cases that trigger crashes during execution, so good test cases are your early-warning system.

Is run-time error on the AP® Computer Science Principles exam?

Run-time errors show up in multiple choice, usually in one of two ways. First, scenario classification: you get a description like "a program divides a number by a user input" and have to recognize that an input of 0 causes a run-time error, not a syntax or logic error. Second, definition matching: a stem asks which option "best describes a run-time error," and the right answer is the one tied to execution, not to broken language rules or wrong output. Questions also probe why run-time errors are trickier than errors caught before execution, since they can depend on specific inputs and only surface when the program is actually running. No released FRQ has used this term verbatim, and since 2023 the AP CSP exam no longer includes the written Create response anyway, so MCQ classification is where this term earns its points.

Run-time error vs logic error

Both happen while the program runs, which is why they get mixed up. The difference is the symptom. A run-time error stops or crashes the program during execution (divide by zero, accessing something that doesn't exist). A logic error lets the program finish normally but produce incorrect or unexpected results, like using + when you meant *. Crash means run-time; wrong answer means logic.

Key things to remember about run-time error

  • A run-time error is a mistake that occurs during the execution of a program, which means the program started running before it failed.

  • Dividing by zero is the go-to AP example, especially when a user input could be 0, because the error only appears for that specific input.

  • Each programming language defines its own run-time errors, so the exact behavior depends on the language being used.

  • Run-time errors crash or stop the program, while logic errors let the program finish but produce wrong results, and syntax errors prevent the program from running at all.

  • Testing with inputs at or just beyond the extremes (EK CRD-2.J.2) is the main strategy for catching run-time errors before users hit them.

Frequently asked questions about run-time error

What is a run-time error in AP Computer Science Principles?

It's a mistake in a program that occurs during the execution of the program, defined in EK CRD-2.I.3. A common example is dividing by zero, which only fails once that line of code actually runs.

Is a run-time error the same as a syntax error?

No. A syntax error breaks the rules of the programming language and stops the program from running at all. A run-time error only happens while the program is executing, so the code passed the language's rules but failed in action.

How is a run-time error different from a logic error?

A run-time error crashes or halts the program during execution, like dividing by zero. A logic error lets the program run to completion but produce incorrect or unexpected results. One stops the program; the other gives you a wrong answer.

Does dividing by zero cause a run-time error?

Yes, in most languages it does, and it's the classic AP CSP example. The error only triggers during execution when the divisor actually equals zero, which is why testing inputs like 0 matters.

Why are run-time errors harder to catch than syntax errors?

Syntax errors get flagged before the program runs, but run-time errors often depend on specific inputs and only appear during execution. That's why EK CRD-2.J.2 tells you to test with inputs at or just beyond the extremes, since edge-case inputs are what trigger these crashes.