| Introduction to OOP | Chapter 11: Static and Dynamic Behavior: | next | previous | audio | real | text |
A message can produce a compile error, even if no run-time error could possibly arize:
class Mammal { }
class Dog extends Mammal {
void speak() { System.out.println("woof"); }
}
Mammal pet = new Dog;
pet.speak(); // will generate error, Mammals don't speak