aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes catching general exceptions before Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "catching general exceptions before" Watch "catching general exceptions before" New topic
Author

catching general exceptions before

Romeo Ranjan
Ranch Hand

Joined: Feb 23, 2009
Posts: 95
source: Examlab for SCJP 6.0


compiling the above code,this is the error that i get.


can someone explain me why i get this? I understand that Exception is more general when compared to RuntimeException which is specific?the answer should have been e.am i wrong?RuntimeException IS A Exception,is that correct??


SCJP 6.0
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Romeo Ranjan wrote:RuntimeException IS A Exception,is that correct??

What JavaDocs says ?

And about error, study the multiple catch block defining rules.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Rohan kanade
Ranch Hand

Joined: Oct 22, 2009
Posts: 106
RunTimeException is a subclass of Exception , So it must be declared in a catch clause before Exception because it is narrower/precise than Exception.

btw you can neglect catching a runtimeException, it and its subclasses are unchecked exceptions.


SCJP 1.6 ,SCWCD 5
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

Rohan kanade wrote:RunTimeException is a subclass of Exception , So it must be declared in a catch clause before Exception because it is narrower/precise than Exception.....
you can neglect catching a runtimeException,

Please be serious with the class names.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: catching general exceptions before