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 oops in java?
What is the benefit of singleton pattern?
What’s the difference between applets and standalone program?
What is ctrl m character?
What is the difference between array list and vector in java?
How can a gui component handle its own events in java programming?
What is number data type?
What is a ?
I am a fresher and know core java, c languge, html, css etc if I am illegible for any job then send it on my email tatranakshay276@gmail.com
What is difference between static class and singleton pattern?
What is the ==?
Is oracle java 11 free?
How do I print a “?
How to create an interface?
What is an immutable object? How do you create one in java?