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 is use of static in java?
What is the difference between path and classpath variables?
What is overriding in java?
What is meant by final class?
Explain the inheritance?
Why scanner is used in java?
How to sort array in descending order in java?
What are benefits of java?
If goto and const is reserve words than why it is not work in java?
What is a numeric string?
What is data type in computer?
What is the public field modifier?
What is the difference between the file and randomaccessfile classes?
What is abstract class constructor called?
How do you sort a set in java?