aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes on exception handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "on exception handling" Watch "on exception handling" New topic
Author

on exception handling

velan vel
Ranch Hand

Joined: Nov 15, 2005
Posts: 137
hai can any one eaplain this question

whather the finished will be printed or not.

1. public class Test {

2. public static void aMethod() throws Exception {
3. try {
4. throw new Exception();
5. } finally {
6. System.out.println("finally");
7. }
8. }
9. public static void main(String args[]) {
10. try {
11. aMethod();
12. } catch (Exception e) {
13. System.out.println("exception");
14. }
15. System.out.println("finished");
16. }
17. }
What is the result?
A. finally
B. exception
finished
C. finally
exception
finished
D. Compilation fails.
Niranjan Deshpande
Ranch Hand

Joined: Oct 16, 2005
Posts: 1277
answer is C.


SCJP 1.4 - 95% [ My Story ] - SCWCD 1.4 - 91% [ My Story ]
Performance is a compulsion, not a option, if my existence is to be justified.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: on exception handling