Type of Exception
- Checked Exception
- Un-Checked Exception
Checked Exception
Checked Exception are the exception which checked at compile-time. These exception are directly sub-class of java.lang.Exception class.
Only for remember: Checked means checked by compiler so checked exception are checked at compile-time.
Un-Checked Exception
Un-Checked Exception are the exception both identifies or raised at run time. These exception are directly sub-class of java.lang.RuntimeException class.
Note: In real time application mostly we can handle un-checked exception.
Only for remember: Un-checked means not checked by compiler so un-checked exception are checked at run-time not compile time.
Difference between checked Exception and un-checked Exception
Checked Exception | Un-Checked Exception | |
---|---|---|
1 | checked Exception are checked at compile time | un-checked Exception are checked at run time |
3 | e.g. FileNotFoundException, NumberNotFoundException etc. | e.g. ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException etc. |
Difference between Error and Exception
Error | Exception | |
---|---|---|
1 | Can't be handle. | Can be handle. |
2 | Example: NoSuchMethodError OutOfMemoryError | Example: ClassNotFoundException NumberFormateException |
No comments:
Post a Comment