What is the Difference between Overriding and overloading?

Answer Posted / deepika singh

OVERLOADING:- 1) overloaded methods have the same name but
different parameter list.
2)a subclass method can overload a superclass method

eg:-int add(int a, int b)
int add(float a , float b)
are overloaded methods



OVERRIDING:-
it just in inheritance and the overriding
method must hold the same name and the same signatures .
the change maybe just in behavior .


The Cat class in the following example is the subclass and
the Animal class is the superclass. The Cat class overrides
eat() method inherited from Animal class.

public class Animal {

public void eat() {
System.out.println("Eat for Animal");
}
}

public class Cat extends Animal {

public void eat() {
System.out.println("Eat for Cat");
}
}

Is This Answer Correct ?    62 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which is the tool which can convert visual basic old version to .net compatibility version?

531


What are the different variables in vb.net?

520


Explain the services provided by common language infrastructure.

722


What is code security?

528


What is vb.net used for?

552






Using VB, how can you change the Mouse Pointer?

639


What is a static variable?

561


How to view an assembly?

597


what is interface and when it is used?

1833


Explain about delegate?

519


How do you script this scenario in QTP using VB? Verify XML attributes in XML message against XSD and data mapping of fields to Oracle tables? Verify data in XML to data in a defined table?

2557


What is global assembly cache (gac)?

562


What is the use of console application?

580


What is the differnce between managed code and unmanaged code?

541


Explain and brief about rapid application development tool?

588