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
If a class is declared without any access modifiers, where can the class be accessed?
Can size_t be negative?
What is balanced tree in java?
Why charat is used in java?
What is the difference between a window and a frame in java programming?
Do loops java?
Explain about the performance aspects of core java?
How can an exception be thrown manually by a programmer?
How do you sort arraylist in descending order?
How do you convert bytes to character in java?
How can you read content from file in java?
What is package protected in java?
If system.exit (0); is written at the end of the try block, will the finally block still execute?
Which are different kinds of source code?
Does java trim remove newline?