What are the different types of errors in Java?
Updated: Sep 26, 2019
Basically there are 3 types of errors in java.
Compile time errorLogical errorRun time error
1. Compile-time error→
It occurs during the compilation phase. It is due to the syntax not followed is solved by the programmer
compile-time mean time between the conversion of source code to intermediate code(mean conversion of .java file to .class file)
Ex:- like if I write int if=0; then according to the syntax of identifier we can’t use a reserved word in java I used if as an identifier which is reserved word in java so we didn’t follow syntax so we will get a compile-time error.
2. Logical error—->
It occurs during run time. It is due to wrong representation or misrepresentation of logic.due to it wrong result or inconvenient result. It occur at the program development level.
Ex:- like I need to find the addition of 2 numbers but at a place of + sign by mistake I use – sign then I will get the wrong result because I implement wrong logic.
3. Run time error→
It occurs during run time. It is due to wrong or invalid input enter by the user. It occur at the implementation level.
Implementation level means the level at which application used by the client/user.
Ex:- like I made a program to find output of division of 2 numbers like x/y and I will get z as an output user will provide value of x and y at run time suppose user enter value of y as 0 then it is invalid input because any number divided by 0 so we will get NumberFormatException (run time error).
No Fields Found.