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 is mnemonic in assembly language?
Explain implementation and how is it different from conversion?
Can list have duplicates in java?
What is identifier give example?
Why java applets are more useful for intranets as compared to internet?
Explain about object oriented programming and its features?
Can you call one constructor from another if a class has multiple constructors?
Can a class have multiple constructors?
Which arithmetic operations can result in the throwing of an arithmeticexception?
What are the 6 boolean operators?
What is the statements?
What is ctrl m character?
What are different type of exceptions in java?
Is object a data type in java?
What is method overloading with type promotion?