• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Runtime exceptions??

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

my doubt is can the Runtime exceptions be caught ??
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any class that extends the "Throwable" class can be caught using the try/catch block. (Includes both Exceptions and Errors)

Since "RuntimeException" indirectly extends this class, it can very well be caught. I dont see any issues.
 
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Have a look at the code ..and try to execute it


Hope you can figure it out...
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The same question was asked last week. As said in the previous post .
Any class that's an instance of java.lang.Throwable can be caught.
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes kumar i have executed the ur code ..

coz of the last Runtime exception it is giving me the fatal exception ...
which was not put in the try catch block ...

that means u can catch the runtime exceptions also...

thanks
sri
 
A Kumar
Ranch Hand
Posts: 980
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Srikkanth..

What i wanted to show you was that we can catch Runtimeexceptions...(first exception..in try block)

or if you dont..the runtime environment handles it..(second one without try-catch block)

Hope you doubt is cleared..

Also look at srinivas's post..he has rightly pointed out..


Any class that's an instance of java.lang.Throwable can be caught.



Checked exceptions..you have to catch....in try catch block

Unchecked ...you can catch if you want..or you need not catch it..Its your decision..

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic