Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

try/catch/finally..................

 
Amit Punjwani
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I have posted a lot many questions
I found this question in Javaprepare mock exams. But I have certain doubts
59) Which of these statements are true. Select all correct answers.
A] For each try block there must be at least one catch block defined. //false
B] A try block may be followed by any number of finally blocks. //false only one finally allowed
C] A try block must be followed by at least one finally or catch block. //it should be false
it should be phrased as "A try Block must be followed by at most one finally or zero or more catch blocks." of course finally should be last.
D] If both catch and finally blocks are defined, catch block must precede the finally block //true finally must come last
Given ans : C, D
My ans : Only D for the above reasons.
Am I right? or probably the third is not phrased correctly.
Any Comments....
 
Ray Hsieh
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Amit,
C is correct. A try can't stand by itself, it has to be followed either by exactly one finally or one or more catch clauses.
Cheers.
Originally posted by Amit Punjwani:
I guess I have posted a lot many questions
C] A try block must be followed by at least one finally or catch block. //it should be false
it should be phrased as "A try Block must be followed by at most one finally or zero or more catch blocks." of course finally should be last.
Am I right? or probably the third is not phrased correctly.
Any Comments....

 
Ira Jain
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,
Check out the following site http://www.geocities.com/SiliconValley/Network/3693/obj_sec2.html#obj7
It gives a good idea of the try -catch block.
Hope it helps
Ira
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic