File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes What is covariant type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "What is covariant type" Watch "What is covariant type" New topic
Author

What is covariant type

Nancy Antony
Ranch Hand

Joined: Sep 06, 2007
Posts: 145

HI Ranchers,

K&B pg 111 says,"In Overriding return type can’t change except for
covariant returns."

What does it mean exactly?

Regards,
Nancy
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Did you do a simple google search??


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

Here is a more fancy URL

http://lmgtfy.com/?q=what+is+a+covariant+return


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Ankitt Gupta
Ranch Hand

Joined: Feb 19, 2009
Posts: 101
Covariant type means your return type of the overriding method should be subclass of the return type of overridden method.

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Deepak Bala wrote:Here is a more fancy URL

http://lmgtfy.com/?q=what+is+a+covariant+return


Stephen Davies
Ranch Hand

Joined: Jul 23, 2008
Posts: 352
Ankitt Gupta wrote:Covariant type means your return type of the overriding method should be subclass of the return type of overridden method


I would say Ankitt it may be a subclass be not that it should be.


be a well encapsulated person, don't expose your privates, unless you public void getWife()!
Ruben Soto
Ranch Hand

Joined: Dec 16, 2008
Posts: 1032
Or it could be an implementing class, or an extending interface, if the return type of the overridden method is an interface. The key is that the covariant return must pass the Is-A test for the return type of the overridden method.


All code in my posts, unless a source is explicitly mentioned, is my own.
Nancy Antony
Ranch Hand

Joined: Sep 06, 2007
Posts: 145

Thanks Ranchers
 
jQuery in Action, 2nd edition
 
subject: What is covariant type