A good answer might be:

The catch{} blocks are in a correct order, because ArithmeticException is not an ancestor nor a descentant of NumberFormatException. The other order of the two blocks would also work.

Possible Exceptions

The code in the try{} block might throw (1) an IOException, (2) a NumberFormatException, or (3) an ArithmeticException.

    try
    {
      System.out.println("Enter the numerator:");
      inData = stdin.readLine();
      num    = Integer.parseInt( inData );

      System.out.println("Enter the divisor:");
      inData = stdin.readLine();
      div    = Integer.parseInt( inData );

      System.out.println( num + " / " + div + " is " + (num/div) );
    }

An IOException might occur in either readLine() statement. There is no try{} block for this type of exception, so the method has to say throws IOException.

A NumberFormatException might occur if the user types in "Rats" or other characters that can't be converted to an int. There is a try{} block for this type of exception,

An ArithmeticException might occur if the user enters data that can't be used in an integer division. There is a try{} block for this type of exception,

QUESTION 12:

What type of exception is thrown if the user enters a 0 for the divisor?

Click Here after you have answered the question