It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes CHecked Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "CHecked Exception" Watch "CHecked Exception" New topic

CHecked Exception

Sandy Lee

Joined: Jan 18, 2001
Posts: 18
In very simple terms, checked exception are a subset of the exceptions that are checked by the compiler and flagged(code will not compile) if they are not handled by the method
1. either in a try catch block or
2. not propogated by that method by declaring the method as throws SomeChecked excpetion.
Of the Exception class, there is the RunTimeException subclass and its sub classes and there are other subclasses.The RuntimeException and its subclasses are not checked exceptions.

The other exceptions include IOException and its subclasses for e.g.
A simpler way to remember is that all Exception other than
1. Exception class.
2. RuntimeException and its subclasses
are checked exception.
Trust this helps.
Jeff Sky

Joined: Feb 15, 2001
Posts: 9

Except for RuntimeException, Error and their subclass, all exceptions are called checked exceptions.
the compiler ensures that if a a method can throw a checked exception , derectly or indirectly, the the method must explicitly deal with it.
the method must either cathch the cxeption and take the appropriate acton, or pass on the exception to its caller.

Swati Jambhale

Joined: Jan 26, 2001
Posts: 22
I wanted to know, if we are calling a finalize() method ,why we have to catch the Throwable exception or we have to mention that it throws this exception
public static void main(String s[]) throws Throwable
new Object().finalize();
why we have to include a throws clause or we have to catch this exception.
Is Throwable/Exception is consider as a Checked Exceptions ?

public void fun()
// code not throwing any IOExceptions
catch(IOException e)
this code will cause an compile time error. as IOException is checked exception.
public void fun()
//code not throwing any kind of exception
catch(Exception e)
This is compile and run perfectly
Is there is some rule which i am missing

I agree. Here's the link:
subject: CHecked Exception
It's not a secret anymore!