This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes return type of method 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 "return type of method" Watch "return type of method" New topic
Author

return type of method

Janki Shah
Ranch Hand

Joined: Nov 23, 2011
Posts: 136

According to k&b covariant type is possible. But this class does not have a Has-A or Is-A relationship.
gurpeet singh
Ranch Hand

Joined: Apr 04, 2012
Posts: 924
    
    1

there is no obligation on the return type of the method as long as it follow java syntax rules and compiles. why are you saying that the method cannot return variable of the type Main. the co-variant type is for overridding methods. Overriding is related to inheritance. when a method overriddes another method then the overridding method can have co-variant return type ,which means its return type can be any sub-class of the return type of overridden method. there is nothing stopping you from returning object of another class from your methods.
Janki Shah
Ranch Hand

Joined: Nov 23, 2011
Posts: 136
Thank you Gurpeet for clearing my doubt.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return type of method