Starting from:

$17

Chapter 9 - Exception Handling

Exercise 1: How would the dialogue in Display 9.1(InputMismatchExceptionDemo) change if you were to omit the following line from the catch block? (Try it and see.) keyboard.nextLine(); 2 3 4 5 6 7 8 9 10 11 Exercise 12: Define an exception class called PowerFailureException. The class should have a constructor with no parameters. If an exception is thrown with this zero- argument constructor, getMessage should return "Power Failure!" The class should also have a constructor with a single parameter of type String. If an exception is thrown with this constructor, then getMessage returns the value that was used as an argument to the constructor. 13.................................................................................................................................. Exercise 31: What is the output produced by the following program? What would the output be if the argument to exerciseMethod were −42 instead of 42? (The class NegativeNumberException is defined in Display 9.8, but you need not review that definition to do this exercise.)

More products