what is the purpose of the final in the try-catch-final

Answer Posted / guest

finally will execute after catch block if try throw
exception else it will execute after try.

ex:

class a
{
public static void main(String []asd)
{

try
{
throw new Exception();
}catch(Exception e)
{
System.out.println("catch");
}
finally{
System.out.println("finally");
}
}
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain notifyall() method of object class ?

664


Difference between serialization and deserialization in java?

650


Can an interface have a class?

562


What do you understand by Header linked List?

590


Variables used in a switch statement can be used with which datatypes?

513






What is the main purpose of serialization in java?

525


Why static functions are used?

563


What is the meaning of find and replace?

524


What is boolean query?

526


How can you avoid serialization in child class if the base class is implementing the serializable interface?

634


What restrictions are placed on method overloading?

601


Can a constructor call the constructor of parent class?

535


What does main method?

558


What is downcasting?

567


What is the difference between length and length() method in java?

639