What is the Difference between Overriding and overloading?
Answers were Sorted based on User's Feedback
Answer / lakshmi prabha
OverLoading : All the method will share the same name but
it differes based on the parameter, type of parameter and
number of parameter
Overriding : The method in the derived class the has the
same name in the base class and it changes the behaviour or
functionality of the method in the base class.
Is This Answer Correct ? | 250 Yes | 24 No |
Answer / prachee
overloading has same method but different types of
parameters, number of parameters.
overloading does not take return type to differentiate
overloaded method.
ex:
int add(int a, int b)
int add(float a , float b)
are overloaded methods
overriding comes with inheritance concept.
here parent and child both contains the same method. and
when execution takes place; child's method is called.
Is This Answer Correct ? | 124 Yes | 14 No |
Answer / nazrul
overriding->
1) method should be public.
2)it need inheritance.
3)it need virtual keyword before it declartion.
4)it have same name with same parameter in diffrent class.
5)it require non-static method.
6)method should have same datatype.
Overloading->
1)method can be different access speicifier.
2)it doesn't need inheritacne.
3)all method should be in same class.
4)method can have diffrent datatypes
Is This Answer Correct ? | 88 Yes | 8 No |
Answer / 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 |
Answer / sudhakar singh rajput
1-OverLoading is Resolved at COMPILE TIME.But Overridding is
resolved at RunTime.
2-OverLoaded Methods Can Change Access specifiers.in
overridding the access level of overridden method(in derived
class) must not be more restrictive than that of overridden
method(of base class)
3-Overloaded methods can declare new exceptions.But
overridden method must not throw new exceptions than those
declared by overridden method.
Is This Answer Correct ? | 51 Yes | 10 No |
Answer / yugal
OVERLOADING is the process of declaring the methods having
the same name but diff signatures. Signature means diff
types & number of arguments.
OVERRIDING is the process of overwriting the methods of
base class in Derived Class.
Overriding is the example of run-time polymorphism and
Overloading is the example of compile-time polymorphism.
Overloading
1) Method can have different access specifier.
2) Method can have different return type
3) Method must have same name with different method
signatures.
4) It doesn't need inheritance as method should be in
same class.
Overriding->
1) Method must have same access specifier.
2) Method must have same return type.
3) Method must have same name with same method
signatures.
4) It needs inheritance and virtual keyword before it
declaration.
5) It requires non-static method.
Is This Answer Correct ? | 27 Yes | 5 No |
Answer / omar
overriding: it just in inheritance and the overriding
method must hold the same name and the same signatures .
the change maybe just in behavior .
overloading : maybe in inheritance or in other way but must
to do overloading must the method hold the same name and
must change signatures.
remark:we can not only change th return type.
Is This Answer Correct ? | 35 Yes | 16 No |
Answer / sanjay
1-OverLoading is Resolved at COMPILE TIME.But Overridding is
resolved at RunTime.
2-OverLoaded Methods Can Change Access specifiers.in
overridding the access level of overridden method(in derived
class) must not be more restrictive than that of overridden
method(of base class)
3-Overloaded methods can declare new exceptions.But
overridden method must not throw new exceptions than those
declared by overridden
Is This Answer Correct ? | 28 Yes | 9 No |
What is the diff between vb mdi form and .net mdi form?
Explain the difference between value and reference types?
What is the difference between datagrid and gridview?
when do we need a multiple document interface?
code for export,import,save,update,delete ?
Why do we use ansi keyword?
What is portable executable?
What is trace in vb.net?
Display a roll having minimum marks in two subjects?
Write a VB.Net console program to check whether a number is perfect or not.
What are the advantages of VB.NET?
what is delegates