0% found this document useful (0 votes)
20 views1 page

Abdo Sharaf - Compilers Task 1

Uploaded by

Ahmed abd elbaki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Abdo Sharaf - Compilers Task 1

Uploaded by

Ahmed abd elbaki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Compilers

Dr. Heba El Hadidy

Task (1) - Runtime Errors vs Compile Errors


‫ – علوم الحاسب‬802320061 – ‫عبد الحميد أشف شف‬

Compile Errors Runtime Errors


Occur during the compilation Occur while the program is running.
phase of the program. The These errors happen when the
compilation is the translation of the instructions being executed encounter
high-level programming language an unexpected situation that the
Definition
into machine code. programmer didn't account for, such as
division by zero, attempting to access
an index out of bounds in an array, null
pointer exceptions, etc.
Occur due to syntactical or Occur due to logical errors, incorrect
structural issues in the code. These assumptions, or unexpected input
could include syntax errors, type during the execution of the program.
Cause
mismatch errors, missing
semicolons, undefined variables,
etc.
Detected by the compiler when you Detected while the program is
attempt to compile the code. executing. They often cause the
Detection
program to terminate abnormally
(Crash) or behave unexpectedly.
If there are compile errors in your When a runtime error occurs, the
code, the compiler will not program may crash or produce
generate an executable file or incorrect results. Unlike compile errors,
bytecode. You cannot run the which prevent the program from
Consequences program until all compile errors are running altogether, runtime errors can
fixed. occur even if the code compiles
successfully.

In Java, if you forget to close a Suppose you write a program that


bracket, misspell a keyword, or use expects a user to input a number, but
a variable without declaring it, you the user enters a letter instead, causing
Examples will encounter compile errors. the program to attempt a mathematical
operation on a non-numeric value. In
that case, you will encounter a runtime
error.

You might also like