Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!
  • 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

About exception execute!

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi :
All ! I have a question about exception execute !
Question 16: What appears in the standard output if the method named problem() in the code below throws an instance of class Exception when the method named trythis() is invoked?

Select all valid answers.
a) "1"
b) "2"
c) "3"
d) "4"
e) "5"
tha answer is a,c,d . But I think e)also should be print !
I know that when there is some exception cannot be catched , finally block will execute and after finally will never execute!
Now , I think this should excute because no exception cannot be catched. Can anyone tell me mine is wrong or right ?
(Marilyn added code tags)

[This message has been edited by Marilyn deQueiroz (edited November 04, 2001).]
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The finally block executes no matter what (except when there is a System.exit call before a call to the finally block).
The catch block executes only if an exception is thrown.
In your case, if an instance of class exception is thrown, the try catch block dealing with that particular exception gets executed and the finally block is run after that.
The statement after the finally block is not executed because there is a return statement in the catch block that dealt with the exception.
What I have said here is the very tip of the iceberg regarding exception handling. There are a great deal of permutations and combinations to deal with. You may want to take this as a start and explore further. Writing code snippets and learning from the compiler is the way I would recommend.
Hope this helps
Shyam
 
juan Tsui
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank Shyamsundar Gururaj !
Thanks Shyamsundar Gururaj for your advice and help !
I will take test this week !
I hope I will win in the test!


 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My best wishes for your exam..you'll come out with flying colors. BTW...I am taking my exam this friday
Good Luck
Shyam
 
reply
    Bookmark Topic Watch Topic
  • New Topic