Syntactic vs. Semantic vs. Runtime Errors

The following are three Java examples for showing what are syntax error, semantic error, and runtime error.

Syntactic Error

If a program contains syntax error, it will not pass compilation.

public static int returnNull(){

Semantic Error

If a program contains only semantic errors, it means that it can pass compilation, but does not do what it meant to do. It c

public static int calSquareArea(int sideLength){
	return sideLength * 2;

Runtime Error

Runtime errors happen during program run-time.

public static void main(String[] args) {
public static int devideInt(int a, int b){
	return a/b;

Leave a Comment