what are the rules to use try catch finally?

Answer Posted / naveen

Rules to using try catch finally blocks.

First thing is try,catch and finally blocks are used in
Exception Handling.In try block we are write Exception
rising code in catch block using exception handling code and
finally block is used to releasing the resource. try and
catch blocks are executed are not finally block is executed.
we are using this combination

try{
//Exception rising Code
}catch(Exception e){

}finally{
//releasing the resource
}

2)
try{
//Exception rising Code
}catch(Exception e){

}

3)try{
//Exception rising Code
}finally{
//releasing the resource
}

Is This Answer Correct ?    11 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is enhanced loop in java?

550


What is the use of static methods?

589


How can constructor chaining be done using this keyword?

589


What are the new features in java 8? Explain

561


Explain differences between checked and unchecked exceptions in java?

641






what is heap memory?

658


Can we write multiple catch blocks under single try block?

577


Can we extend singleton class in java?

547


Is array passed by reference in java?

582


What is preparedstatement in java?

564


What are the advantages of functions?

523


Why is string buffer better than string ?

603


What do you mean by inner class in java?

568


What’s the difference between unit, integration and functional testing?

616


Can anonymous class have constructor?

552