samar
try and finally block
1 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

hello,

If I write

System.exit (0);

at the end of the try block,

will the finally block still execute?

Advertisement
View Answers

October 25, 2010 at 11:05 AM


hii,

if we use

System.exit (0);

statement any where in our java program it will always terminate our program.

so finally will not execute!!










Related Tutorials/Questions & Answers:
try and finally block
try and finally block  hello, If I write System.exit (0); at the end of the try block, will the finally block still execute?   hii... it will always terminate our program. so finally will not execute
finally block
finally block  hii, If I am writing return at the end of the try block and some code in finally block, then the finally block will execute??   hello, certainly finally block will execute
Advertisements
closing connections in finally block
closing connections in finally block  Hi, What will happen if I close connection before closing the resultset in the finally clock? e.g. finally... { ... conn.close(); rs.Close(); } If i do as above ... what will happen
Example to show Finally exception in java
;     Finally block are the block, that executed when the try block exits. This block executed even after the unexpected exception occured.The Run time always execute the expression in finally block irrespective
Finally in java
Finally in java In this section we will discuss about finally block in java. Finally block always execute when try block exits. Finally is a block of code that execute after try/catch block. finally will execute whether exception
java: try finally blocks execution
java: try finally blocks execution  java: try finally blocks execution
Java try, catch, and finally
, catch and finally block is given below: try { / ... Java try, catch, and finally         The try, catch, and finally keywords are Java keywords
The finally Keyword
execution of a try block. It is always a good practice to use finally clause after... block. It becomes possible because the finally block always executes when the try.... It is used when the finally block is executed after the execution exits the try block
Maximum number of catches for a try block
Maximum number of catches for a try block  How many catch statements are allowed for a try statement?   Hello Friend, You can use any number of catch statement for a try statement. Thanks
Exception Handling with and without using try catch block
Description: Without using try catch block. If you do not want to explicitly make try catch block then to you program write throws Exception to your... is by using try catch block shown in following code sample:  class
Java finally
a good practice to use finally clause after the try and catch block to handle... the finally block always executes when the try block exits and it is also useful...; In java, there are three clauses named try, catch and finally used
finally in flex
, the finally block will run even when an error is thrown: try { throw new Error... block can appear after the try and catch blocks, and it can contain code..."); } finally { trace("finally"); } //output: try, finally Since no error is thrown
Nested try catch
be written in the try block.  If the exceptions occurs at that particular block then it will be catch by the catch block. We can have more than one try/catch block. We can declare multiple try blocks inside the try block. The most
Nested Try-Catch Blocks
that, a try statement can be inside the block of another try. If an inner try... blocks concept where an inner try block is kept with in an outer try block...! If the outer try block's statements run successfully
Multiple try catch
be written in the try block.  If the exceptions occurs at that particular block then it will be catch by the catch block. We can have more than one try...Multiple try catch      
Finally() in Java
Finally() in Java  After an exception i excute some statement in Finally block.After Fianally block we can execute statements??? if possible... exception1; } Catch(exception1 e) { .... } Finally { try{ }catch(Exeception e
SCJP Module-6 Question-6
block without 'catch'. 2.No errors. Prints :   Inside try...; at end of the code 3. Can't use try block inside main. 4.  Finally must be after 'catch'. Answer : (2) Explanation : Can use 'try
Try catch in JSP
Try catch in JSP          In try block we write those code which can... it is caught inside the catch block. The try catch block in jsp just work as try catch
Nested try
different outputs ie my exception gets executed first then finally block and vice versa.pl explain me class Demo { static void nestedTry(String args[]) { try...("Div by zero error!"); } finally { System.out.println("Finally"); } } public
Nested try
: java Demo 2 3, it will give output 0 , the try block of method is called which.... java Demo 3 2, it will give output 0 , the try block of method is called which...(String args[]) { try { int a = Integer.parseInt(args[0]); int b
Statement block
Statement block  What is the purpose of a statement block
Java Function for block inside a block
Java Function for block inside a block  Write a function in Java that attempts to place a set of squares of varying widths into another, larger square. If there is no possible layout, return undefined. Otherwise, return
Java Function for block inside a block
Java Function for block inside a block  Write a function in Java that attempts to place a set of squares of varying widths into another, larger square. If there is no possible layout, return undefined. Otherwise, return
try Java Keyword
: -- The try keyword in java programming language is used to wrap the code in a block... of  an exception object. -- Every try block in java programming language must...; try{ <block of code that may throw exceptions> } catch (<
Try it Editor
Try it Editor  Hello sir...actually i want to add an html,css & js editor like in w3 school try it editor 1.5....can you tell me how i can add it..pllz plzzz rppy soon
try catch
try catch  why following code gives compile time error.please reply...=1;i<=3;i++) { System.out.println(i); try...); try { Thread.sleep(1000
Try and catch in Exception Handling.
. Then to perform exception handling, we have used try and catch block where we have divided the integer value by 0 in the try block. This results in an Arithmetic...Try and catch in Exception Handling.  How can we use try and catch
java try catch
java try catch  try{ return 1; }catch(exception e){ return 2; } finally{ Return 3; } What is the out put if any exception occurred
Try Ruby
Try Ruby       Try out Ruby code in this site, by typing the ruby code then see the result. Read full Description
doubt on synchronized block in java
doubt on synchronized block in java  Hi ! some people are feeling... suggestinons.Today i am going to ask on synchronized block. the general form of synchronized block is class table { ....... void printTable(int n
Is catch(){} block synchronized?
Is catch(){} block synchronized?  The code in catch(){} block behaves synchronized. In one block, if I do {write to file1; write to file2}, and in another {write to file2; write to file1}, they deadlock. Is this implicit sync