Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....


 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic