Consider the following program:
public class Question33
{
public static void main(String[ ] args)
{
try
{
sampleMethod(99);
}
catch(Exception e)
{
System.out.println("Caught in main.");
}
}
public static void sampleMethod(int n) throws Exception
{
try
{
if (n > 0)throw new Exception();
else if (n
throw new NegativeNumberException();
else
System.out.println("No exception.");
System.out.println("Still in sampleMethod.");
}
catch (NegativeNumberException e)
{
System.out.println("Caught in sampleMethod.");
}
finally
{
System.out.println("In finally block.");
}
System.out.println("After finally block.");
}
}
a. What output does the program produce?
b. What output would the program produce if the argument to
sampleMethod were −99 instead of 99?
c. What output would the program produce if the argument to
sampleMethod were 0 instead of 99?