read following code,why the code1 compile while the code2 not.Give me something about the item.
code1:
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");
}
}
code2:
public class AQuestion
{
public static void main(String args[])
{
System.out.println("Before Try");
try
{
}
catch(java.io.IOException t)
{
System.out.println("Inside Catch");
}
System.out.println("At the End");
}
}
the code1 ans :3(No compiler error. The lines "Before Try" and "At the end" are printed on the screen. )
the code2 ans :1(Compiler error complaining about the catch block where no IOException object can ever be thrown. )