Why we need Finally with try?
pls expain with ur example..
Answer Posted / 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 View All Answers
What is the difference between final, finally and finalize() in java?
How do you delete a list in java?
What is the importance of main method in Java?
Explain the polymorphism principle?
What is parsing and its types?
Implementations of set interface?
How big is a boolean?
What are the different approaches to implement a function to generate a random number?
Can we overload destructor in java?
Differentiate between nested and inner class in java.
What is java lang object?
What is a variable declaration?
What is the purpose of garbage collection in java? When is it used?
Is finalize() similar to a destructor?
Discuss about garbage collector in Java.