that the overriding method has the right type. While some languages require that the type exactly matches the type in the superclass (invariance), it is also type safe to allow the overriding method to have a "better" type. By the usual subtyping rule for function types, this means that the overriding method should return a more specific type (return type covariance), and accept a more general argument (parameter type contravariance). In UML notation, the possibilities are as follows (where Class B is the subclass that extends Class A which is the superclass): For a concrete example, suppose we are writing a class to model an animal shelter. We assume that is a subclass of , and that we have a base class (using Java syntax) class AnimalShelter { Animal getAnimalForAdoption() { // ... } void putAnimal(Animal animal) { //... } } Now the question is: if we subclass , what types are we allowed to give to and ? Covariant method return type In a language which allows covariant return types, a derived class can override the method to return a more specific type: class CatShelter extends AnimalShelter { Cat getAnimalForAdoption() { return new Cat(); } } Among mainstream OO languages, Java, C++ and C# (as of version 9.0 ) support covariant return types. Adding the covariant return type was one of the first modifications of the C++ language approved by the standards committee in 1998. Scala and D also support covariant return types. Contravariant method parameter type Similarly, it is type safe to allow an overriding method to accept a more general argument than the method in the base class: class CatShelter extends AnimalShelter { void putAnimal(Object animal) { // ... } } Only a few object-oriented languages actually allow this (for example, Python when typechecked with mypy). C++, Java and most other languages that support overloading and/or shadowing would interpret this as a method with an overloaded or shadowed name. However, Sather supported both covariance and contravariance. Calling convention for overridden methods are covariant with out parameters and return values, and contravariant with normal parameters (with the mode in). Covariant method parameter type A couple of mainstream languages, Eiffel and Dart allow the parameters of an overriding method to have a more specific type than the method in the superclass (parameter type covariance). Thus, the following Dart code would type check, with overriding the method in the base