Exceptions are one of the important concept of Java.
Exception: Exceptions are nothing but Run-time error which comes in program due to Logical errors in program like "Divide by Zero", "Null pointer Exception" etc. Exception is a class in java. Sometimes there is no Compilation Error (Syntactical error) in your program but due to some errors at run-time like wrong user input error may arise and your program will be abruptly closed.
Fig: Exception Class Hierarchy
So, To avoid your program to be closed abruptly, you must know how to handle Exception by using "Try-Catch" block.
There are two types of Exception:
1) System Defined (handled by throws/throw)
2) User Defined (handled by throw)
There are various Exception classes in java like:
- ArrayIndexOutOfBoundsException
- DivideByZeroException
- IOException
- NullPointerException and many more...
For more Details Refer following link:

No comments:
Post a Comment