This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: on exception handling
 
Similar Threads
Why Compiler Error.
A question in finally
Try catch flow
try catch finally question
can't understand the output