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 skeleton and stub? What is the purpose of those?
What does exclamation mean in java?
What do you mean by an interface in java?
What are streams?
How do you check whether the list is empty or not in java?
What are java annotations?
Explain reverse a linked list recursive java solution?
What all methods are used to prevent thread execution ?
4.1 Supply contracts (in the form of comments specifying pre- and post conditions) for the enqueue() method of the LinkedQueue class given in the Appendix. (2) 4.2 Let Thing be a class which is capable of cloning objects, and consider the code fragment: Thing thing1 = new Thing(); //(1) Thing thing2 = thing1; //(2) Thing thing3 = (Thing) thing1.clone(); //(3) Explain how the objects thing2 and thing3 differ from each other after execution of the statements. (
Where is the singleton class used?
What do you mean by light weight and heavy weight components?
If system.exit (0); is written at the end of the try block, will the finally block still execute?
What is bom encoding?
Why put method is used?
Difference between arraylist and vector.