aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes explain try catch problem 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 "explain try catch problem" Watch "explain try catch problem" New topic
Author

explain try catch problem

vineet walia
Ranch Hand

Joined: Feb 16, 2008
Posts: 138


can any body explain why this is giving error
this question is from exam lab ?
Nitish Bangera
Ranch Hand

Joined: Jul 15, 2009
Posts: 537

Yeah because exception1 and exception2 are both checked exceptions and when you are catching a checked exception, there should be a statement in the try block which throws or declares that it throws that checked exception. I guess the explanation given by examlab is pretty much clears that point.


[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
Jaydeep Mazumdar
Greenhorn

Joined: Aug 26, 2009
Posts: 23
I think the error message is pretty self explainatory:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unreachable catch block for exception1. This exception is never thrown from the try statement body
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: explain try catch problem