java Api provided try catch finally ,try catch(its ok) but why try finally and exception occured at try then how the flow is?

Answer Posted / vandana singh

If you want to do a task that must be perform with every situation when exception occurs or not. that you should write the code for this in finally block. cause finally block execute in both situation exception occurs or not.

if an exception occurs then catch block statements execute after that control transfer to finally block.

if any exception not occurs than control transfer to finally block.

Is This Answer Correct ?    25 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is overriding possible in java?

501


Explain about data types?

571


What Is Composition?

578


What is a singleton puppy?

530


What is data type modifier?

529






Is finalize() similar to a destructor?

546


I want to print “hello” even before main is executed. How will you acheive that?

655


What is a treeset in java?

542


What is stringbuffer in java?

541


What is a function argument in java?

515


What is the maximum size of array in java?

512


How do you define a method?

509


Can we use a default constructor of a class even if an explicit constructor is defined?

647


How do you add an element to an arraylist in java?

483


Where to store local variables?

579