could you tell me the difference between checked exceptions and unchecked exceptions with some examples.i am getting a bit confused between the two. thank you.
Checked Exceptions are the those Exceptions which the compiler forces you to declared or catch it. If you dont you ll get a compiler error. Example of this IOException and all Subclasses of Exception excluding Runtime Exceptions.
Unchecked Exceptions are those Exceptioons which are not required to be caught or handled. All sublclasses of RuntimeException are unchecked Exceptions like ClassCastException ,ArrayIndexOutOFBounds,NullPointerException , etc.
Ther is no harm if you declare or handle the exception, though its better not to , But you will not get a compiler error for not declaring or handling such Exceptions.
Hope it is clear.
The future belongs to those who believe in the beauty of their dreams.Dream BIG!