• 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
  • Paul Clapham
  • Tim Cooke
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Junilu Lacar
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst
  • Peter Rooke
  • Mikalai Zaikin
Bartenders:
  • Himai Minh

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.
 
Yeah, but is it art? What do you think tiny ad?
Master Gardener Program
https://coderanch.com/t/771761/Master-Gardener-Program
reply
    Bookmark Topic Watch Topic
  • New Topic