There are 2 methods in a class. Both have the same method
signature except for return types. Is this overloading or
overriding or what is it?

Answer Posted / debapriya maity

See overloading has nothing to do with Covariant Return
types ,in fact overloading dosent take into consideration
the return types.

But in case of ovveriding u can provide Covariant return type

say for example

class A {
protected A getModel(){
return this;
}
}
class B extends A{

public B getModel(){

return this
}
}
and there are many other examples of
covariant return types like this.

Since B is A(IS-A RelationShip)
so the return type can be a subclas of the super class

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does snprintf return?

551


What is ellipsis in java?

580


How to declare objects of a class ?

589


What is use of static method?

536


Explain about the select method with an example?

591






What are the Class Libraries ?

599


What invokes a thread's run() method in java programming?

571


what is predefined function in java?

539


In which language java is written?

539


What is the reason behind using constructors and destructors?

558


What is try-with-resources in java?

613


How do you create a first line indent?

508


What is parsing and its types?

588


What is the association?

557


What is the difference between math floor and math round?

504