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
What is deep copy?
Is it necessary to have SQL server installed in your computer in order to create a service based database in vb.net?
What is the main purpose of garbage collector?
What are the assembly entry points?
What are the technology areas that microsoft.net contains?
Explain the use of new keyword?
How many languages are supported by .net?
List the different types of assembly?
How many ways the function can return values?
Explain about visual basic?
Explain clr?
What is the feature anonymous type?
What is redim keyword?
How can we remove handlers at run time?
Explain the services provided by common language infrastructure.