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

Explain about the security aspect of java?

656


I want to re-reach and use an object once it has been garbage collected. Define how it’s possible?

673


Name the components that are termed to be Heavy-weight component but available in Light-weight components?

2078


Can we convert list to set in java?

606


What is the difference between state-based unit testing and interaction-based unit testing?

593






What is bitwise complement?

601


What is native method in java?

658


Can you achieve runtime polymorphism by data members?

702


Difference between string s= new string (); and string s = "abv";?

842


Can you access the private method from outside the class?

603


java program with complete 4 oops concepts implemented example

2809


What is the loop in java?

672


what is meant by abstract class?

732


How many bytes is a string java?

624


What is the generic class?

618