wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Runtime exceptions?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Runtime exceptions??" Watch "Runtime exceptions??" New topic
Author

Runtime exceptions??

srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252

my doubt is can the Runtime exceptions be caught ??


Thanks & Regards<br /> <br />-Srikanth
Ashwin Kumar
Greenhorn

Joined: Oct 13, 2005
Posts: 27
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.


SCJP 1.4<br />SCBCD 5.0<br />SCWCD 1.4 (Preparing)
A Kumar
Ranch Hand

Joined: Jul 04, 2004
Posts: 979
Hi,

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


Hope you can figure it out...
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
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.


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
srikanth reddy
Ranch Hand

Joined: Jul 28, 2005
Posts: 252
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

Joined: Jul 04, 2004
Posts: 979
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..

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Runtime exceptions??