Menu
Topics Index
...
`

Try And Finally


If you need explanation Read this topic

If you need Answer Take test on this topic

Try And Finally
What will be the output of the following program?
import java.net.*;

public class TryBlockOnly
{
    public static void main(String a[]) throws MalformedURLException
    {
        try
        {
            URL url = new URL("http://www.meritcampus.com");
            System.out.println(url);
        }
        finally
        {
            System.out.println("In finally block");
        }
    }
}

A. http://www.meritcampus.com
In finally block
B. http://www.meritcampus.com
C. In finally block
D. Compilation Error
E. Runtime Error
Topic: Unknown

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is A....try block is executed first and then finally block executes

Posted by Badam Swathi    2014-07-07 13:30:54


A

Posted by Yeshu Yeshwanthi    2014-07-07 13:31:20


ans a bcz
first in try block, URL object is created and url specifier is initialized then printed
then finally block is executed and prints"In finally block"

Posted by Pooja Singh    2014-07-07 13:40:39


Ans A : finally will always be executed after try...

Posted by BalRam At    2014-07-07 15:08:21


ans a only bcoz the flow in the normal

Posted by Din Kurth    2014-07-08 01:30:28


Congratulations Badam Swathi. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-08 04:28:49


© meritcampus 2019

All Rights Reserved.

Open In App