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

What is the difference between convert.tostring and .tostring() method?

532


Name some different types of control?

538


difference between control and component more than one differences

2422


Sir, what code to store data from vb net sql server 2008 to 2005 and at the same time in order to validate the data entered is not the same, but there have been contacts in the module. Examples such as the log table that I created, the user name as the primary key.

1763


What is the main use of a namespace?

530






What is a static variable?

571


What are the features present in vb 2005?

579


What is strong typing and weak typing?

555


What is the purpose of an Assembly?

616


What are all the differences between dispose and finalize()?

565


Which dll is used for microsoft .net run time?

561


What is an arraylist?

590


Which classes a dll can contain?

544


What are nested classes?

549


Can you please explain the difference between dataset and datareader?

560