aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes try/catch/finally.................. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "try/catch/finally.................." Watch "try/catch/finally.................." New topic
Author

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

Amit Punjwani
Ranch Hand

Joined: Jul 10, 2000
Posts: 50
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

Joined: Sep 20, 2000
Posts: 59
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

Joined: Sep 06, 2000
Posts: 70
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
 
 
subject: try/catch/finally..................
 
Similar Threads
try/catch/finally
try-catch statement
try-catch-finally
catch{} blocks
try {} catch() {} finally {}