17 February 2021

Summary of subtyping

If S and T are types then S is a subtype of T if:

Warning! Things that are NOT True

Generics and Inheritance

picture describing the principles above

Exceptions

The root of the class hierarchy for error handling is the class Throwable. Its name sounds like an interface but it is actually a class.

Throwable has two descendants, Error and Exception. Errors generally describe conditions that are fatal and graceful recovery from them in not possible. The result is program death. Subclasses of this inclue StackOverflowError and OutOfMemoryError. Exceptions describe conditions that are less drastic. You have seen these. These are all subclasses of RuntimeException

Checked Exceptions An exception is a checked exception if it is not a subclass of RuntimeException. Code that can throw these must be placed in a try block.

FileIO can raise checked exceptions, so you will learn how to handle them properly.

picture describing the throwable subtree