Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

CHecked Exception

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
------------------
Jeff
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello
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
i.e
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

 
Well don't expect me to do the dishes! This ad has been cleaned for your convenience:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic