• Post Reply Bookmark Topic Watch Topic
  • New Topic

Method Overriding - covarent returns not applicable for primitive datatypes  RSS feed

 
Pushkaraj Thorat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,

I have small question; regarding Overriding the methods having the covariant returns of primitive data types...

Covariant returns: When super class non static/non final function is returning an class type; then in Subclass while overriding, the returned may be replaced with the subclass of parents return type.

now we can represent this as,

return_type_overriddenfn = return_type_overridedfn

/* That is reference of the return type can be of overridden func.. can be assigned with the return type of overrided function.*/

But in the case of Premitive type this dosn't happen...
though



goes well...

Code example... /*it will not compile*/



I was thinking that what reason restricted to covariant returns only for classes.

Thanks,
Pushkaraj
 
Pushkaraj Thorat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take me out of this..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!