When return type of the method of super class is different than the return type of method of subclass and it
is also a method overriding then it is known as covariant return type.
And here the return type is non primitive.
I am writing the simple example of covariant return type.
class Abc{
Abc get(){return this;}
}
Class Xyz extends Abc{
Xyz get(){return this;}
void show(){
System.out.println("Got covariant type.!!!");
}
public static void main(String args[]){
new Xyz().get().show ();
}
O/P:
Got covariant type.!
0 Comment(s)