Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

doubt in Exception

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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
 
I AM MIGHTY! Especially when I hold this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic