• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Exception Doubt

 
Ranch Hand
Posts: 180
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the diffrence between Checked Exception and unchecked Exception.
is that runtime exceptions are unchecked Exceptions and they are derived from RuntimeException.
 
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Checked Exceptions are always checked by the Compiler. The compiler throws errors if the Checked exceptions are not handled or declared.

Unchecked Exceptions on the other hand are not checked by the compiler and yes, they are subclasses of RuntimeException. Whether you choose to handle or declare them, the compiler doesn't care.

More on this topic: http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html

Hope this helps.
 
Ranch Hand
Posts: 629
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For Checked Exceptions you need try-catch blocks. You need not try-catch Unchecked(Runtime) Exceptions.

Thanks.
 
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All throws exception are Checked Exception.Compiler makes sure that a block capable of throwing a CheckedException must/should associate a handler for it.Which if neglected would generate a compile-time error.
Example : Block having a Class.forName("class name") statement should throw(s) ClassNotFoundException. Neglecting a handler for Unchecked exception doesn't worry compiler.
 
Ashok Pradhan
Ranch Hand
Posts: 180
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
IllegalArgumentException is a checked Exception or UnChecked Exception.
 
Sidharth Pallai
Ranch Hand
Posts: 137
Hibernate Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ashok,
IllegalArgumentException is definetly an Unchecked Runtime Exception,which would prop-up during runtime when when a method is invoked with an argument which it can not reasonably deal with.
Check for categorised exceptions,you will know the list.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ashok Pradhan:
IllegalArgumentException is a checked Exception or UnChecked Exception.


To find the answer, lookup IllegalArgumentException in the API documentation to find out whether it is a subclass of RuntimeException or not.
 
Ashok Pradhan
Ranch Hand
Posts: 180
Netbeans IDE Eclipse IDE Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is that mean all the checked Exceptions are not RuntimeException and they are not either direct subclass or subclass of subclasses.
[ June 30, 2008: Message edited by: Ashok Pradhan ]
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes - Any exception that has RuntimeException as a superclass (either direct or higher up the inheritance chain) is an unchecked exception, and other exceptions are checked exceptions.
 
reply
    Bookmark Topic Watch Topic
  • New Topic