Compile time error happens when your program has one or more syntax errors.
What is syntax error? Every programming language dictates how
you should write your program. If you want drive a car without getting booked in front of the watchful police officer than you don't jump the red lights. If you don't want the compiler errors than you follow the
Java rules book (jls).
Runtime error occurs when you violate the rules during the execution of the program. In order to run the program, it should pass the compiler first. So, it doesn't have any syntax violatations.