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

Explain the private protected method modifier?

547


Why is it important to initialize a variable?

492


What methodology can be utilized to link to a database?

506


Where are global variables stored?

509


Describe the Big-O Notation.

616






What is the difference between the font and fontmetrics classes in java programming?

505


What are the methods available in a class?

587


What is difference between static and final?

561


What is thread safe in java?

553


Explain 5 features introduced in jdk 1.7?

613


List out benefits of object oriented programming language?

487


Difference between linkedlist and arraylist.

592


Is main an identifier?

546


Explain the difference between an Interface and an Abstract class?

631


What is the integer of 16?

539