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 a literal control?
give me code for selecting itemcode and correspondin vendor details wll displays in the gridview?
Name and explain some of the exclusive features which are present in vb?
Explain the difference between c# and vb.net?
What is break mode? What are the options to step through code?
what's ArrayList in .Net (VB.Net or C#).What's the advantageous using ArrayList.
Compare c# and visual basic.net?
What is code access security?
What is the feature which is common to all .net languages?
hi dear ? MY problem is that i m developing software for Library. and i want to connect a third party software with my VB.net program in order to calculate DDC number.I dont know how to do this if any body can help me please?
What is the difference between convert.tostring and i.tostring method?
Write a program that would find the nth term of a geometric progression, given the value of first term and common ratio. Any inbuilt function that the language provides for calculating exponent should not be used.