Hello I have a doubt regarding Try/catch and Finally . Now will "Finally" execture even if there is no catch block after Try. That is if The runtime System throws an exception Due to the absence of the Catch Block will the Finally Block Still be Executed.?
Now in the above example i have commented the catch block but this is the output i get an Arithmetic Exception but the finally block never gets exectued. can u please Help me thanks
Gowri Venkatesh
manasa teja
Ranch Hand
Joined: May 27, 2002
Posts: 325
posted
0
The finally gets executed always, if it is present, except special cases like, System.exit Even in ur example also, the output is Hello Exception in thread "main" java.lang.ArithmeticException: / by zero at divbyzero.main(divbyzero.java:9) It directly goes to Finally block as the exception is not caught and exceutes finally and gives exception. HTH
MT
Tauqueer Ali
Ranch Hand
Joined: Sep 05, 2001
Posts: 53
posted
0
this code doesn't even compile gives the following error message while compiling cannot compute value of expression: class Error const *.
SCJP2, SCWCD, XML, OOAD<br />Kolkata, India
suresh kamsa
Ranch Hand
Joined: Jul 30, 2001
Posts: 149
posted
0
The code compiled and raised Arithemetic exception after printing Hello on the screen. Sample output. -------------- Hello Exception in thread "main" java.lang.ArithmeticException: / by zero at test.main(test.java:9)
Ron Newman
Ranch Hand
Joined: Jun 06, 2002
Posts: 1056
posted
0
I get: divbyzero.java:9: Arithmetic exception. int y=10/0; at compile time. Do different compilers act differently when they see constant integer division by 0?
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
suresh kamsa
Ranch Hand
Joined: Jul 30, 2001
Posts: 149
posted
0
The code compiled and raised Arithemetic exception after printing Hello on the screen. Sample output. -------------- Hello Exception in thread "main" java.lang.ArithmeticException: / by zero at test.main(test.java:9)
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.