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


Please Help Members By Posting Answers For Below Questions

Why are constructors used?

757


Can we create a constructor in abstract class?

773


What is the use of toarray () in java?

798


Difference between string, string builder, and string buffer?

761


Define array. Tell me about 2-D array.

826


If a method is declared as protected, where may the method be accessed in java programming?

722


What is the generic class?

722


What ide should I use for java?

739


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

1602


What is the use of StringTokenizer class?

830


What is == in java?

783


Why use string handling in Java?

809


Explain the difference between abstract class and interface in java?

763


What are pass by reference and pass by value?

719


Are global variables initialized to zero?

724