*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Covariant returns Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Covariant returns" Watch "Covariant returns" New topic
Author

Covariant returns

Sathya Shanmugam
Ranch Hand

Joined: Mar 02, 2007
Posts: 45
Hi folks,

Could any give more examples for covariant returns, Any link would be appreciated..


thanks
Sathya Shanmugam
Ranch Hand

Joined: Mar 02, 2007
Posts: 45
And also like to have some explanation with example for the following statement from KB book

" Overriding methods can do so only within the bounds of covariant returns"...
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Sathya,

" Overriding methods can do so only within the bounds of covariant returns"...




New Thing to learn: You may have heard of bridge method; How does JVM handle to call the overridden method with covariant return type; The compiler automatically inserts the following in the subclass(in out example)

Animal meth() {
return this.meth();
}


Hope you got the concept!

Thanks & Regards,
cmbhatt


cmbhatt
Sathya Shanmugam
Ranch Hand

Joined: Mar 02, 2007
Posts: 45
Thanks chan for your immediate reply

I don't know what is a bridge method :roll:
 
jQuery in Action, 2nd edition
 
subject: Covariant returns
 
Similar Threads
covariant returns
Covariant Returns
query related overriding.
including covariant return ?
Need help for method selection