File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IBM Mock Exam: Try Catch Finally ?

 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 185
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic