| Author |
Exception Doubt
|
Ashok Pradhan
Ranch Hand
Joined: Dec 17, 2007
Posts: 179
|
|
What is the diffrence between Checked Exception and unchecked Exception. is that runtime exceptions are unchecked Exceptions and they are derived from RuntimeException.
|
 |
Denise Advincula
Ranch Hand
Joined: Jan 01, 2007
Posts: 153
|
|
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.
|
SCJP/OCPJP 6 | SCWCD/OCPJWCD 5 | OCPJBCD in progress
|
 |
Arjun Reddy
Ranch Hand
Joined: Nov 10, 2007
Posts: 622
|
|
For Checked Exceptions you need try-catch blocks. You need not try-catch Unchecked(Runtime) Exceptions. Thanks.
|
Be Humble... Be Nice.
|
 |
Sidharth Pallai
Ranch Hand
Joined: Apr 21, 2008
Posts: 134
|
|
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.
|
Thanks & Regards
Sidharth Pallai
|
 |
Ashok Pradhan
Ranch Hand
Joined: Dec 17, 2007
Posts: 179
|
|
|
IllegalArgumentException is a checked Exception or UnChecked Exception.
|
 |
Sidharth Pallai
Ranch Hand
Joined: Apr 21, 2008
Posts: 134
|
|
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.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12911
|
|
To find the answer, lookup IllegalArgumentException in the API documentation to find out whether it is a subclass of RuntimeException or not.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Ashok Pradhan
Ranch Hand
Joined: Dec 17, 2007
Posts: 179
|
|
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
Bartender
Joined: Aug 16, 2005
Posts: 12911
|
|
|
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.
|
 |
 |
|
|
subject: Exception Doubt
|
|
|