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


Please Help Members By Posting Answers For Below Questions

Is there a sort function in java?

565


How does varargs work in java?

595


How define set in java?

499


how to split string in java?

641


What is the difference between the jdk 1.02 event model and the event-delegation model introduced with jdk 1.1?

602






Can we override the static method?

558


Explain about features of local inner class?

579


Does list maintain insertion order java?

521


What is the size of integer?

572


Do we have pointers in java?

519


What are different types of constants?

504


What is a boolean flag in java?

552


Is main a function?

500


What does replaceall do in java?

471


Why array is used in java?

500