Introduction to OOP Chapter 11: Static and Dynamic Behavior: next previous audio real text

Importance of Static Class

In a statically typed object-oriented language, the legality of a message is determined at compile time, based on the static class.

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
Intro OOP, Chapter 11, Slide 07