Page 88 - Trackpad_ipro 4.1_Class8
P. 88
For example:
public class SyntaxError{
public static void main(String args[])
{
int a = 100;
int b = 200;
int c = a * b
System.out.println(c);
}
}
}
In the preceding program, the statement "int c = a * b" produces an error because we have
not added the semicolon at the end of the line. We have also added an extra bracket at the
end of the class. So, the compiler shows an error message for the same.
Runtime Errors
Runtime errors are those that occur at runtime. These errors interrupt the program execution
abnormally. When a runtime error occurs, the program terminates its execution even if it has
compiled successfully. Runtime errors are also known as exceptions.
One of the most commonly occurring runtime errors is the 'division by zero' error. It occurs
when we divide a number by zero. For example,
public class RuntimeError{
public static void main(String args[])
{
int a = 100;
int b = 0;
int c = a / b;
System.out.println(c);
}
}
If we compile the preceding program, it compiles successfully. But, when we run the program,
it will show an error message as follows:
86 iPro (Ver. 4.1)-VIII

