• 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

try block

 
Ranch Hand
Posts: 30
  • 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 from being executed when an exception is caught, you can:


a) Code a return statement in the catch clause.

b) Call System.exit() in the catch clause.

c) Code a return statement in the finally clause.

d) Code an end clause.

e) None of the above.

is it a,b,d or a,b,c ?
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Venkat, tell us what do you think. Why each of the answer can be right or wrong.
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi! Venkat
The only correct answer is b. Only System.exit() statement will prevent execution of code that is after the try block. If you code a return statement, the finally will still get executed if you have it.

Originally posted by Venkat Ramanan:
To prevent code which follows a try block from being executed when an exception is caught, you can:


a) Code a return statement in the catch clause.

b) Call System.exit() in the catch clause.

c) Code a return statement in the finally clause.

d) Code an end clause.

e) None of the above.

is it a,b,d or a,b,c ?


reply
    Bookmark Topic Watch Topic
  • New Topic