CS 1401, Quiz #9

Date: Tuesday, November 8, 2005
Name (please type legibly, ideally in block letters): ______________________________________________________________________

Below is the code for a class testing exceptions. Note that doing a parseInt on a string that's not an integer causes a NumberFormatException and that dividing by zero causes an ArithmeticException.


public class q9code
{
  private static String s=?;
	
  public static void main(String[] args)
  {
      try
      {
          System.out.println("A");
          int i = Integer.parseInt(s);
          System.out.println("B");
          int j = 4/i;
          System.out.println("C");
      }
      catch (ArithmeticException err)
      {
          System.out.println("D");
      }
      finally
      {
          System.out.println("E");
      }
      System.out.println("F");
  }
}
1. Show the output of this code if the string s is initialized to "1".







2. Show the output of this code if the string s is initialized to "0".







3. Show the output of this code if the string s is initialized to "a".