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
Explain the difference between an xml "fragment" and an xml "document."
Explain strong name in .net assembly?
What is sealed class?
What is early binding?
what is common language specification?
What is redim keyword and its use?
What are all the parts of .net framework?
write a program to develop a graphic user interface application of marks book with students names and their names.the program should show the following options main menu,add student details,display student details,maximum mark and minimum mark.
What do you mean by serialization?
Explain how to achieve polymorphism in vb.net?
Can you please explain the difference between int and int32?
Define manifest?
What are the features present in vb 2005?
What is the use of assembly?
What is different between web.config and machine.config and where it will be ?