In Java, exception handler acts as a flag to catch an error and makes the program run smoothly. When an error is encountered during execution of a program, an exception is said to have occurred. This disrupts the program. A compile-time error happens when the program is being compiled. Generally, compile-time errors are syntax errors; and they are caught by the compiler. A run time error occurs during the execution of a program. Exception handling is the process of responding to anomalous occurrence or exceptional events during execution of a program. The two types of errors are compile time errors and runtime errors. Compile time errors are a result out of violation of programming language’s grammar rules. They are caught by java compiler. Run time errors occur when program with no syntax errors asks the computer to do something that computer is unable to reliably do. Exception handling clarifies code and enhances readability. It simulates consequences, as error handling takes place at one place and in one manner. Exception handling makes clear-robust and fault-tolerant programs. Java uses try-catch-finally syntax to test section of code and to trap error, if any error occurs in that region. The finally keyword can be used to provide a block of code that is always performed regardless of whether an exception is signaled or not.
To Access the full content, Please Purchase