Why we need Finally with try?
pls expain with ur example..

Answers were Sorted based on User's Feedback



Why we need Finally with try? pls expain with ur example....

Answer / kedar lasane from tuljapur

Because Some Instructions that must be executed in our java
program though there is exception in try block caught by
catch.Once the Exception occurs it catched by catch
statement and control never goes to try block again.So to
Execute some statements after subsequent with try block then
finally {} block is used.Hopefully You find your solution.If
any questions regaurding to java just mail me.
--------------
thnx
my blog: http://www.tuljabhavani.in

Is This Answer Correct ?    34 Yes 4 No

Why we need Finally with try? pls expain with ur example....

Answer / uppaluri

Finally Block always executes when the try block exists. Finally is used for more than exception handling : It allows the Programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice. Hopefully you find your Solution.If you have any questions regarding Java mail me

Is This Answer Correct ?    16 Yes 6 No

Why we need Finally with try? pls expain with ur example....

Answer / neha

finally block gets executed in both scenarios I.e exception occurs or doesn't occur..it is used to write the code which we want to execute in both successful or failed scenarios..generally code for cleaning up resources added in finally block.e.g closing file,closing socket connection.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer



More Core Java Interview Questions

Explain Connection Pooling?

3 Answers  


Difference between string, stringbuffer and stringbuilder?

0 Answers  


What is main in java?

0 Answers  


what is mena by object block any what is the use of that

0 Answers   CGI,


Define how destructors are defined in java?

0 Answers  






Which variable is the independent variable?

0 Answers  


What is the function of static in java?

0 Answers  


Create a form of user Login in JSP, that accepts the user name and password from user and authenticate it with user names and passwords stored in database. (Plz provide me answer immediately)

1 Answers   ABC,


Write a regular expression to validate a password. A password must start with an alphabet and followed by alphanumeric characters; its length must be in between 8 to 20.

0 Answers  


What is the purpose of void?

0 Answers  


What is the differences between c++ and java? Explain

0 Answers  


What is tcp ip in java?

0 Answers  






Categories