File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception Question from Enthuware Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception Question from Enthuware" Watch "Exception Question from Enthuware" New topic
Author

Exception Question from Enthuware

nav katoch
Ranch Hand

Joined: May 02, 2008
Posts: 246

Consider the following code snippet:


Which of the following statements are true?

A. If IOException gets thrown at line1, then the whole method will end up throwing SQLException.
B. If IOException gets thrown at line1, then the whole method will end up throwing CloneNotSupportedException.
C. If IOException gets thrown at line1, then the whole method will end up throwing InstantiationException()
D. If no exception is thrown at line1, then the whole method will end up throwing CloneNotSupportedException.
E. If SQLException gets thrown at line1, then the whole method will end up throwing InstantiationException()

Answers:- B, D

Could anybody please explain?

Thanks!!!


[HENRY: Added Code Tags]
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
Hint: Whatever the case finally block will always execute if your code reaches in try{}catch block, until you use System.exit();


SCJP 6
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

1--if there exists a finally block after try or catch block ,it does not matter(except system.exit) what happens in the try or catch block the finally block will be exectued.

one exception would be discarded if another exception is thrown before handling the first one.
Hope this two points help you in figuring out the answer.
[EDIT: Oops ! i did not notice punit's hint. Sorry gave away the answer ! !]


SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
nav katoch
Ranch Hand

Joined: May 02, 2008
Posts: 246

Thanks Punit and James. Thanks Henry for adding code tags.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception Question from Enthuware