Variance
Variance is the correlation between the subtyping relationships of complex types and the subtyping relationships of their component types.
Covariance
A type parameter T of a generic class can be made covariant by using the annotation +T.
Here is the program for your reference:

Contravariance
A type parameter A of a generic class can be made contravariant by using the annotation -A.

Invariance
Generic classes in Scala are invariant by default.
