InterviewSolution
| 1. |
What are the differences between error and exception in Java? |
||||||||||||||
|
Answer» An error occurs when a user performs an unauthorised action that causes the code to behave abnormally. Errors in programming are frequently UNNOTICED until the code is compiled or run. Some of the errors make it impossible to compile or run a program. As a result, errors should be removed before COMPILING and running a program. Out of memory and system crash are two examples of errors. In Java, an exception is an unwelcome or unexpected occurrence that occurs during the program execution, or during run time, and disturbs the usual flow of the program's instructions. Exceptions are circumstances that arise during the program execution and may result in its termination. However, try, catch, and throw keywords can be USED to recover them. Unchecked exceptions (exceptions which are not checked at compile time), such as ArrayIndexOutOfBoundException, are KNOWN to the compiler at runtime, whereas checked exceptions (exceptions which are checked at compile time), such as IOException, are known to the compiler at compile time.
|
|||||||||||||||