File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes try block 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 block " Watch "try block " New topic
Author

try block

Venkat Ramanan
Ranch Hand

Joined: Jan 25, 2001
Posts: 30
To prevent code which follows a try block from being executed when an exception is caught, you can:


a) Code a return statement in the catch clause.

b) Call System.exit() in the catch clause.

c) Code a return statement in the finally clause.

d) Code an end clause.

e) None of the above.

is it a,b,d or a,b,c ?
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Venkat, tell us what do you think. Why each of the answer can be right or wrong.
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java�2 Platform.
IBM Certified Developer - XML and Related Technologies, V1.


Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Latha Kalaga
Ranch Hand

Joined: Nov 13, 2000
Posts: 96

Hi! Venkat
The only correct answer is b. Only System.exit() statement will prevent execution of code that is after the try block. If you code a return statement, the finally will still get executed if you have it.

Originally posted by Venkat Ramanan:
To prevent code which follows a try block from being executed when an exception is caught, you can:


a) Code a return statement in the catch clause.

b) Call System.exit() in the catch clause.

c) Code a return statement in the finally clause.

d) Code an end clause.

e) None of the above.

is it a,b,d or a,b,c ?

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: try block
 
Similar Threads
Exeption Handling Q
Exception ??
Exceptions
IBM Mock Exam: Try Catch Finally ?
Exceptions