Multiple choice

What will be the output of the program?

public class X 
{  
    public static void main(String [] args) 
    {
        try 
        {
            badMethod();  
            System.out.print(A);  
        } 
        catch (RuntimeException ex) /* Line 10 */
        { 
            System.out.print(B); 
        } 
        catch (Exception ex1) 
        { 
            System.out.print(C); 
        } 
        finally 
        {
            System.out.print(D); 
        } 
        System.out.print(E); 
    } 
    public static void badMethod() 
    { 
        throw new RuntimeException(); 
    } 
}

  1. BD

  2. BCD

  3. BDE

  4. BCDE

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

A Runtime exception is thrown and caught in the catch statement in line 10. The code after the finally statement is run because the exception has been caught.