10.1 Dynamic Method Selection Puzzle (Online Only)

10.1.1 A Typing Puzzle


Suppose we have two classes: 有两个类

Summarizing is-a relationships, we have:

For each assignment, decide if it causes a compile error.

For each call to bark, decide whether:

  1. Dog.bark() is called,
  2. ShowDog.bark() is called, or
  3. A syntax error results.

The rules: