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
Can you declare the main method as final?
How can an exception be thrown manually by a programmer?
Can we convert list to set in java?
What is the difference between preemptive scheduling and time slicing?
Why is multiple inheritance not supported in java?
Why is an interface be able to extend more than one interface but a class can’t extend more than one class?
Is break statement can be used as labels in java?
What is singleton class in java and how can we make a class singleton?
Can a java program have 2 main methods?
What is default size of arraylist in java?
How will you initialize an Applet?
What restrictions are placed on method overloading?
How we can skip finally block of exception even if some exception occurs in the exception block in java?
Define max and min heap, also the search time of heap.
can java object be locked down for exclusive use by a given thread? Or what happens when a thread cannot acquire a lock on an object? : Java thread