Introduction to OOP Chapter 16: Overriding : next previous audio real text

Contravariant Return Types

To see how a contravariant change can get you into trouble, consider changing the return types:
	class Parent {
		Mammal test ( ) {
			return new Cat();
		}
	}

	class  Child extends Parent {
		Animal test () {
			return new Bird();
		}
	}

	Parent aParent = new Child();
	Mammal result = aValue.test(); // is this legal?
Most languages subscribe to the novariance rule: no change in type signatures.
Intro OOP, Chapter 16, Slide 23