• 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

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic