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 / ketan gambhir
Overloading:-in overloading,we can use same name of method
and constructor with different parameters in same class.
For Exa:-
\\Both methods has different declaration and definition.
class A
{
public int same(int a int b)
{
return a+b;
}
public void same()
{
System.out.println("ketan");
}
}
Overriding:-In overriding,we can use same method and
constructor with same parameters in different classes.
For Exp:-
class A
{
public void same()
{
System.out.println("same1");
}
}
class B
{
public void same()
{
System.out.println("ketan");
}
}
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What is java life cycle?
What is matcher in java?
What is early binding and late binding in java?
Is set ordered?
What is the unit of plancks constant?
Can we convert integer to string in java?
What are the basics of core java?
What are JVM.JRE, J2EE, JNI?
How do weakhashmap works?
What ide should I use for java?
Is string is a keyword in java?
What are the four corner stones of oop?
Can a static block throw exception?
How many digits can a float hold?
What is the use of pattern in java?