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
What are examples of modifiers?
When would you use a static class?
What are the advantages of java over C++?
What do you understand by overloading and overriding in java?
What are use cases?
What is return data type?
What are parameters in a method?
What access modifiers can be used for class ?
What is an example of a constant variable?
What do you mean by platform independence of Java?
How to avoid memory leak in java?
Can you change array size in java?
What is the difference between processes and threads?
Which is better 64 bit or 32 bit?
What is string value?