What is the difference between compile-time errors and runtime errors?

Before we can run our program on a computer, a compiler translates our human-readable code into machine language - a long string of 0s and 1s. When the code is being compiled, the compiler looks for syntax errors in the code - you can think of it like proofreading.

For example, if the compiler comes across a mispelled word or misused function in your code, it will throw a compile-time error and your code will not even be translated into machine language. Imagine you write 'fro' instead of 'for' or you try to apply the length() function to an integer. These are things that the compiler does not know how to read and therefore it will throw an error.

Runtime errors are different, they are caused after your code has been compiled and is running, by wrong logic or wrong input of data such as division by 0. For example, if you have the following code:

int i = 17;

int[] a = new int[5];

a[i] = 20;

this will give you a runtime error because you are trying to access an element of the array that is out of bounds.

TG
Answered by Teodora G. Computing tutor

3238 Views

See similar Computing A Level tutors

Related Computing A Level answers

All answers ▸

Project Euler Question 3: What is the largest prime factor of the number 600851475143?


What is the decimal equivalent of the following sequence of bits, which represents an unsigned binary integer: 1101001. What is the decimal equivalent if the sequence in bits encodes a two’s complement binary integer.


A common construct found in many algorithms is a loop. Using pseudocode, write a pre-condition loop to output all of the even numbers between 99 and 201.


What is the point of an Operating System?


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2025 by IXL Learning