Covariance and contravariance are principles in type systems that define how type hierarchies relate to each other, particularly in the context of inheritance and polymorphism. Covariance allows a method to return more derived types, while contravariance allows a method to accept parameters of more base types, ensuring flexibility and type safety in object-oriented programming.