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

Explain the difference between an xml "fragment" and an xml "document."

690


Explain strong name in .net assembly?

726


What is sealed class?

808


What is early binding?

687


what is common language specification?

716


What is redim keyword and its use?

768


What are all the parts of .net framework?

727


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.

1372


What do you mean by serialization?

733


Explain how to achieve polymorphism in vb.net?

712


Can you please explain the difference between int and int32?

752


Define manifest?

744


What are the features present in vb 2005?

742


What is the use of assembly?

748


What is different between web.config and machine.config and where it will be ?

778