This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What are the below exception Statement can any one explain them?

 
Lal Mothi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Catch (Exception e),
Catch (Error err),

Catch (Throwable t)
 
Jitendra Jha
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are three Catch statements.As we know that java's Exception handling mechanism is derived from the Throwable interface,so the throwable is at the top of exception hierarchy.it has two subclasses,namely error and exception.we can say that both of these are peer classes.
In your statement,Exceptions of type Exception are handled by Exception catch and of type error will be handled by error catch.
Though java allows catch blocks to be organised in a subclass to superclass order,but i doubt that your code will ever need the throwable catch as all exceptions are handled by the first 2 catch blocks
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!