Hi, I am really confused with checked and unchecked exceptions every time I read and get confused with that. Is there any simple way or trick to check checked and unchecked exceptions from exam point of view(SCJP1.5). Thanks in Advance.
SCJP1.5(81%), SCDJWS(94%), next mission SCEA (but need to wait or that)
Unchecked exceptions are subclasses of RuntimeException, and are usually implemented using IllegalArgumentException, NullPointerException, or IllegalStateException. Checked are subclasses of Exception. It is somewhat confusing, but note as well that RuntimeException (unchecked) is itself a subclass of Exception (checked).
1- Checked exceptions: Compiler doesn't excuse you. You must handle or declare the exception if your code is supposed to throw any checked exception as java.io.FileNotFoundException, java.io.IOException etc. All checked exceptions extend from java.lang.Exception
Unchecked Exception: Where compiler doesn't bother regarding handle or declare rule. All unchecked exception classes extend from java.lang.RuntimeException
Isn't it simple?
Note: java.lang.RuntimeException also extend java.lang.Exception