hello all,
in doing a mock exam i came across this code
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");
}
}
1. Compiler error complaining about the catch block, where no Throwable object can ever be thrown.
2. Compiler error - Throwable Object can not be caught, only Exceptions must be caught.
3. No compiler error. The lines "Before Try" and "At the end" are printed on the screen.
i would have answered 1, but answer is 3. any reason of why compiler doe snot complain that exception will never be raised?
if i replace Throwable with java.io.IOException the compiler complaints...
any hints?
thanks and regards
marco