CS 1713 Introduction to Programming II Spring 2012 Daily Answers


Class 14:

  1. An exception is an object that defines an unusual or erroneous situation.
  2. If a statment can cause a checked exception, that exception must be either caught or thrown. For an unchecked exception this is optional.
  3.    x = Integer.parseInt(s);
    
  4.    try {
          x = Integer.parseInt(s);
       }
       catch (Exception e) {
          x = -1;
       }