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

practice question: what is the output:

 
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am asking you not the compiler...
 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. aMethod() throws exception and is catched AT THE SAME LEVEL so "FileNotFoundException" is written to the console and bMethod() is invoked.
2. bMethod() throws an exception that is NOT CATCHED AT THE SAME LEVEL! => the program ends with an exception.
If you want to correctly catch the exception thrown by bMethod() you must encolse that one in a try catch block. e.g.
try {
bMethod();
} catch (IOException ioe) {
}

Hope it helps,
Miki
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
The new gardening playing cards kickstarter is now live!
https://www.kickstarter.com/projects/paulwheaton/garden-cards
reply
    Bookmark Topic Watch Topic
  • New Topic