Sunday, 19 May 2013

Exception - 5 -




package net.dharmaraj;

public class AQuestion
{
    public static void main(String args[])
    {
        System.out.println("Before Try");
        try
        {
        }
        catch (Throwable t)
        {
            System.out.println("Inside Catch");
        }
        System.out.println("At the End");
    }
}



Compiler error complaining about the catch block,  where no Throwable object can ever be thrown.

1) Compiler error - Throwable Object can not be caught, only Exceptions must be caught. 
2) No compiler error. The lines "Before Try" and "At the end" are printed on the screen. 

No comments:

Post a Comment