Explanation: The aim of the program is to simply show that whether or not an exception is thrown, fi nally
block executes.
/*PROG 11.15 DEMO OF CREATING OUR OWN EXCEPTION VER 1 */
class demo extends Exception
{
demo(String s)
{
/*PROG 11.14 DEMO OF FINALLY RETURNING FROM METHOD */
class JPS14
{
static void fun()
{
try
{
return;
}
fi nally
{
System.out.println("\nFinally executes");
}
}
public static void main(String[] args)
{
fun();
}
}
OUTPUT:
Finally executes
Explanation: In the staticfunction fun, only the try and finally block ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.