GeekInterview.com
Series: Subject: Topic:
Question: 14 of 17

What is the difference between OVERRIDING and OVERLOADING

Asked by: Interview Candidate | Asked on: Jul 3rd, 2005
Showing Answers 1 - 16 of 16 Answers
Hari

Answered On : May 9th, 2005

Overriding - same method names with same arguments and same return types associated in a class and its subclass.  Overloading - same method name with different arguments, may or may not be same return type written in the same class itself.

  
Login to rate this answer.
varsha

Answered On : Jun 13th, 2005

Ya.. u can also sau that Overloading is static Polymorphism and Overridding is dynamic polymorphism.

Yes  1 User has rated as useful.
  
Login to rate this answer.
Sony

Answered On : Jul 3rd, 2005

The best answer is that both overloading and over-riding are different aspects of polymorphism.......;-)  static/early binding polymorphism:overloading dynamic/late binding polymorphism:overriding 

Yes  1 User has rated as useful.
  
Login to rate this answer.
Jayaprabhakar

Answered On : Feb 7th, 2007

Overloading is compile time binding, where as overriding is dynamic binding.A good example that differentiates between overloading and overriding is shown here.
overriding is compile time binding

  
Login to rate this answer.
ramana

Answered On : Oct 6th, 2007

Please clarify the difference class A{void calc(){}int calc(int){}}class B:public  A{void calc(){}}This is just an abstract of the program.If we have a program like this and an object of class B is created and we call b.calc will the compiler first call the method calc of super class or sub class?What will be the effect of virtual key word on this program?Is the calc function over loaded?Can we say this as an example for over riding?

  
Login to rate this answer.
Blah

Answered On : Oct 11th, 2007

Please clarify the difference class A{void calc(){}int calc(int){}}class B:public  A{void calc(){}}This is just an abstract of the program.If we have a program like this and an object of class B is created and we call b.calc will the compiler first call the method calc of super class or sub class?What will be the effect of virtual key word on this program?Is the calc function over loaded?Can we say this as an example for over riding?-------------------------------------------------------------------------In this case, when class B calls a.calc the complier will first look at the signature of calc. Class B needs to either call a.calc() or a.calc(int).

  
Login to rate this answer.
Anil Singh

Answered On : Feb 18th, 2009

View all answers by Anil Singh

Yes  1 User has rated as useful.
  
Login to rate this answer.
milan.kadivar

Answered On : Feb 19th, 2009

View all answers by milan.kadivar

Yes  1 User has rated as useful.
  
Login to rate this answer.
kamesh23

Answered On : Jun 12th, 2009

View all answers by kamesh23

OvERLOADING:  Same function with different arguments                             ADDITION(int x,int y)                               ADDITION(int x ,int y,int z)                              {                                                             {                                  -------------------------                                ---------------                                 --------------------------                               -------------------                               }                                                             }OVERRIDING: Same function with same arguments                                                        ADDITION(int x,int y)                               ADDITION(float x ,float y)                               {                                                             {                                   -------------------------                                ---------------                                  --------------------------                               -------------------                                }                                                             }

  
Login to rate this answer.
charsmichael

Answered On : May 17th, 2010

View all answers by charsmichael

Overriding refers to a situation where a sub-class inherits a method from a super class which may result into adding or changing the methods behaviour while overloading refers to a situation where there are two or more methods in a class with the same name but with different parameter lists.

  
Login to rate this answer.

In a simple way overriding will occur at two classes, overloading in same class

  
Login to rate this answer.
milan_vachhani

Answered On : Nov 22nd, 2010

View all answers by milan_vachhani

Difference between Overriding and Overloading(1) Def. (Overloading) : Two or more function have same name but differ with parameter passed or return type.Def. (Overridding) : Super class method redefine in sub class with same prototype that is called Overriding(2) Overloading is not related with inheritance, while overriding is related with inheritance. means without inheritance overriding is not possible but overloading is possible

  
Login to rate this answer.
PraveenkumarJ

Answered On : Aug 25th, 2011

OVERRIDING.......... Overriding is which is having the same method name, parameter, and return type but must be in different class Overriding example code

Code
  1. class A
  2. {
  3. public void jpr();
  4. {
  5. Sytem.out.println("Have a cup of coffee");
  6. }
  7. }
  8. class B extends A
  9. {
  10. public void jpr();
  11. {
  12. System.out.println("Have 2 cup of coffee");
  13. }
  14. public static void main (String args[])
  15. {
  16. B ob=new B();
  17. ob.jpr();
  18. }
  19. }

  
Login to rate this answer.
harish

Answered On : Sep 8th, 2011

Overloading:in this case method name is same with different arguments and should be defined within the class for ex:
class A
{
void sum()
{

}
void sum(int a)
{

}
}
over riding:in this case method name is same with same arguments i.e name of the method and arguments should be same in both base class and derived class
for ex:
class A
{
void sum(int a)
{

}
}
class B extends A
{
void sum(int a)
{

}
}

  
Login to rate this answer.
Meher

Answered On : May 29th, 2012

Overloading and overriding are different aspects of polymorphism.
Overloading is also called static/early binding polymorphism.
Overriding is also called dynamic/late binding polymorphism.

  
Login to rate this answer.
k.samba

Answered On : Feb 4th, 2014

Overloading is not related with inheritance that mean what

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.