• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Question about try-catch-finally block

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try {
2. tryThis();
3. return;
4. } catch(IOException x1) {
5. System.out.println("exception 1");
6. return;
7. } catch(Exception x2) {
8. System.out.println("exception 2");
9. return;
10. } finally {
11. System.out.println("finally");
12. }
what will appear in the standard output if tryThis() throws a IOException? (I am not sure of the answer)
Ans :
a. "exception 1" followed by "finally"
b. "exception 2" followed by "finally"
c. "exception 1"
d. "exception 2"
 
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If tryThis throws an IOException, then the answer is 1. "exception one" followed by "finally". You can reference one of my earlier answers to your questions on exceptions.
 
You've gotta fight it! Don't give in! Read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic