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).
SCJP 1.5, SCWCD 1.4, SCBCD 5
Joined: Sep 10, 2006
hi, I am confused in that. Sometimes in questions they will ask whether it is Runtime Exception or ...... So so how to get overcome from all these . please suggest me some trick and tips.
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