2/28/08

To Notes

CSC 212 -- 2/28/08

 

Review Questions

  1. Which of these statements are legal if A ← B?

    Ans: A a = new B( ); is legal because any object of B is also an object of A by inheritance.

  2. Define these terms:

    Ans: An Exception object represents an abnormal situation that causes the program to crash unless something is done. A Throwable object is an object that the program can throw (causing the program to crash). Exception and Error are the two derived classes of Throwable. A Virtual method is an overridden method in Java. The exact version of the method depends on the object type, not on the reference variable type.

  3. What is the difference between throwing an exception and catching an exception?

    And: When an exception is thrown, the program crashes. When the exception is caught, the code in the catch block executes.

  4. Give an example of an exception where any method that could possibly throw that exception must announce that possibility.

    Ans: IOException and its derived classes EOFException and FileNotFoundException.

 

Project Proj6