Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Exceptions

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. all exceptions are subclasses of .Throwable class.
2. Exceptions of the Exception subclass may be handled in a try/catch block.
3. Exceptions of the Error subclass should never be handled.
4. if a method does not handle an exception it must be declared in the throws clause. the exception declared in the throws clause may be any exception which is a subclass of Exception but not of RuntimeException.
Are all the points mentioned above correct ???
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IMO, all the points are valid except 2nd.
2nd should be "Exceptions of Exceptions can be handled in try/catch block except 'Runtime Exceptions'.
Please correct me if I'm wrong.
Prabhu.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception subclass only contains checked exceptions, unincluding Runtime exceptions. so 2) should be true, right?
Indy
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi nikhil,
Runtime exceptions can also be put in the throws clause, but it is not of any use, since they are implicitly included!! So, you won't get any compile time/ runtime error, even if you put it in the throws clause.
I tried this program:

It works the same way, even if you remove the throws clause of the divide method definition.
Hope it's of some use
Regards,
suresh.
 
Just the other day, I was thinking ... about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic