Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Covariant Return Type

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 254
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: