• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt in Exception

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Divya Gehlot
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 652
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Divya,
Refer thisLink and if you have doubts post it here.


Regards
Nik
Scjp 1.5
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic