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 IBM Mock Exam: Try Catch Finally ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "IBM Mock Exam: Try Catch Finally ?" Watch "IBM Mock Exam: Try Catch Finally ?" New topic
Author

IBM Mock Exam: Try Catch Finally ?

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
To prevent code which follow a try catch finally block from being executed. When an exception is caught?
a. code a return in the try block
b. code a return in the catch block
c. code a return in the finally block
d. code a System.exit in the try block
e. code a System.exit in the catch block
f. code a System.exit in the finally block
Which on is corrent an why?
Monty6
[This message has been edited by monty6 (edited June 30, 2000).]
Ankur Gupta
Ranch Hand

Joined: Jun 13, 2000
Posts: 66
I believe it should be System.exit(0) in the finally block. The question though is not the exact worded version I suppose!! Kind of difficult to figure out!!
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
To prevent code which follows: a try block, a catch catch block, or a finally block from being executed. When an exception is caught?
Which one is correct and why?
a. code a return in the try block
b. code a return in the catch block
c. code a return in the finally block
d. code a System.exit in the try block
e. code a System.exit in the catch block
f. code a System.exit in the finally block
Monty6
Michal Harezlak
Ranch Hand

Joined: Jul 06, 2000
Posts: 185
Originally posted by monty6:
To prevent code which follows: a try block, a catch catch block, or a finally block from being executed. When an exception is caught?
Which one is correct and why?
a. code a return in the try block
b. code a return in the catch block
c. code a return in the finally block
d. code a System.exit in the try block
e. code a System.exit in the catch block
f. code a System.exit in the finally block
Monty6

I would say all of this actions will prevent of execution of the code following try/catch/finally. The hint would be "�When an exception is caught?" that suggests that we are already in caught block and return or System.exit() within try block is irrelevant,. I am sort of suspecting that author of that questing might have had in mind preventing only execution of code following the try/catch/finally not termination of the entire application witch System.exit() will cause.
a. return call at any point of execution goes back to calling method (if call from try/catch will execute finally block)
b. System.exit kills all threads and nothing is executed any more.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
thank-you
i agree with you but i just was not sure
i am now very and go to bed
enjoy the mid-night oil...
monty6
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IBM Mock Exam: Try Catch Finally ?