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 is the Difference between Final Class && Abstract Class?

613


What type of variable is gender?

540


Explain features of interfaces in java?

548


What is the properties class in java programming?

540


Can a source file contain more than one class declaration?

508






Is age discrete or continuous?

678


What are the java ide's? Explain

521


If we allocate the memory using 'new' & de-allocated using 'free' then what will happen?

588


What do you know about java?

515


What is hashset in java?

522


Why is multiple inheritance not supported in java?

557


What is a protected class in java?

531


Can I extend singleton class in java?

621


How can you make a class serializable in java?

563


Can inner class final?

631