Exception handling: – A exception means errors. It is common to make mistake while developing as well as typing a program. A mistake might lead to an error causing a program to produce unexpected result.
An error may produce an incorrect output or may terminate the execution of the program even may cause the system to crash. It is there for importuned to detect and manage properly all the possible error condition in the program will not terminate or crash during execution errors may broadly be classified into two categories called compile time error and run time error.
Compile time error: – All syntax errors will be detected and displayed by the java compiler and there for these errors are called compile time error. Whenever the compiler displays an error, it will not create .class file. It is there for necessary that we fix all the error before we can successfully compile and run the program.
The java compiler does a nice job of telling us where the errors are in the program. Java provide facility for these types of error handling.
Run time error: – Some time, a program may compile successfully creating the .class file but not run properly. Such program may produce wrong results due to wrong logic or may terminate do to errors such as step ever flow and show on.