Variance is the correlation between the subtyping relationships of complex types and the subtyping relationships of their component types.
A type parameter T of a generic class can be made covariant by using the annotation +T.
Here is the program for your reference:
A type parameter A of a generic class can be made contravariant by using the annotation -A.
Generic classes in Scala are invariant by default.