This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes doubt in Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "doubt in Exception" Watch "doubt in Exception" New topic
Author

doubt in Exception

Divya Gehlot
Ranch Hand

Joined: Sep 10, 2006
Posts: 243
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)
Sundaram Karthick
Greenhorn

Joined: Jun 26, 2007
Posts: 24
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
Divya Gehlot
Ranch Hand

Joined: Sep 10, 2006
Posts: 243
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.
Nik Arora
Ranch Hand

Joined: Apr 26, 2007
Posts: 652
Hi Divya,
Refer thisLink and if you have doubts post it here.


Regards
Nik
Scjp 1.5
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Simple rules:

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

Thanks,


cmbhatt
chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
I think recalling the Exception Tree from

Throwable
||
1 Error 2 Exception
- AssertionError ||
Runtime Compiletime
(unchecked) (checked)
| |
no need to need to play round
play around
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: doubt in Exception
 
Similar Threads
Checked and Unchecked Exceptions
Regarding checked Exception
How to recognise a checked or unchecked exception
Questions from mock Exam !!!
What is difference between Checked and Uncheched exceptions ?