Difference between overloading and Overriding. <Giving a
confusing example to test the concept.>
(also asked in PA Consultancy Group,iflex,Value
chain,IBM,CTS,Accenture, Tarang>
Answer Posted / kabita
overriding is only possible in case of inheritance,bt
overloading is possible incase of both inheritance & same
class.
class A
{
public int add();
public float sub();
public float multi(float a,float b){}
public double div(double d,double e){}
}
class B extends A
{
public int add(int a,int b){}//must be same as declared in
super class
public float sub(float a,float b){}//must be same name same
returntype same as declared
public float multi(float a,float b,float c){}
}
| Is This Answer Correct ? | 12 Yes | 9 No |
Post New Answer View All Answers
What comes to mind when someone mentions a shallow copy in java?
What is a qualifier in a sentence?
Why strings in java are called as immutable?
What is the difference between numeric and integer?
How do I get the | symbol on my keyboard?
What is the use of optional ?
What do you mean by an interface in java?
What is package private scope in java?
I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?
What is the final class modifier?
Describe different states of a thread.
Can I overload to string method
What is a boolean output?
What is an object in java and how is it created?
What is functional interface in javatpoint?