• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

IBM Mock Exam: Try Catch Finally ?

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
All that thinking. Doesn't it hurt? What do you think about this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic