Hi,
I'd just like to ask if anyone would be able to help me find the out put of this peice of code...i took it from a past exam paper,,,,,and i was wondering wat the output maybe...
thanks
I'd just like to ask if anyone would be able to help me find the out put of this peice of code...i took it from a past exam paper,,,,,and i was wondering wat the output maybe...
Code:
public class UsingExceptions {
// execute application
public static void main( String args[] )
{ // call method1
try {
method1();
}
// catch Exceptions thrown from method1
catch ( Exception exception ) {
System.err.println( exception.getMessage() + "\n" );
exception.printStackTrace();
}
}
// call method2; throw exceptions back to main
public static void method1() throws Exception
{
method2();
}
// call method3; throw exceptions back to method1
public static void method2() throws Exception
{
method3();
}
// throw Exception back to method2
public static void method3() throws Exception
{
throw new Exception( "Exception thrown in method3" );
}
} // end class Using Exceptions
Comment