Menu
Topics Index
...
`

Exception Handling by using trycatch blocks


If you need explanation Read this topic

If you need Answer Take test on this topic

Exception Handling by using trycatch blocks
What will be the output of the following program?
public class DemoOnException
{
    public static void main(String[] args)
    {
        try
        {
            poorMethod();
            System.out.print("A");
        }
        catch (Exception exception)
        {
            System.out.print("B");
        }
        finally
        {
            System.out.print("C");
        }
        System.out.print("D");
    }
    public static void poorMethod()
    {
        throw new RuntimeException();
    }
}

A. ABCD
B. BCD
C. CD
D. BC
E. Compilation Error or Runtime Error
Topic: Java Throw Keyword - Java Throws Keyword

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.

b

Posted by Simer Wadhwa    2014-07-30 04:19:27


b..as wen it enters into try blok.it goes to poor method().
this method is throwng runtime excptn
so catch blok wil b calld n prints B.finaly statemnt is executed wether or not an excptn.is thrown.so it wil print c..and at the end it will execute the print statmnt by prntng D

Posted by Asma Mujtaba Khan    2014-07-30 05:10:26


b.

Posted by Shubham Bansal    2014-07-30 05:17:48


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

Posted by Merit Campus    2014-07-31 04:35:55


© meritcampus 2019

All Rights Reserved.

Open In App