import java . io . * ;
class Test {
{
try
{
throw new Exception ( ) ;
}
catch ( IOException e )
{
System . out . println ( e ) ;
}
}
Test ( ) throws Exception{ } // Comment this line
public static void main ( String args [ ] ) throws Exception {
System . out . println ( " GodSmack " );
}
};
Above program compiles and run fine
but when I comment following line
Test ( ) throws Exception{ } // Comment this line
It gives me follwing compiler error
unreported exception java.lang.Excep tion; must be caught or declared to be thrown
class Test {
{
try
{
throw new Exception ( ) ;
}
catch ( IOException e )
{
System . out . println ( e ) ;
}
}
Test ( ) throws Exception{ } // Comment this line
public static void main ( String args [ ] ) throws Exception {
System . out . println ( " GodSmack " );
}
};
Above program compiles and run fine
but when I comment following line
Test ( ) throws Exception{ } // Comment this line
It gives me follwing compiler error
unreported exception java.lang.Excep tion; must be caught or declared to be thrown
Comment