What is method Overloading ? What is this in OOPS

Showing Answers 1 - 2 of 2 Answers

kmhariharan

  • Sep 15th, 2005
 

Method Overloading : In oops,it is Polymorphism,(i.e) one which takes more than One Form. Method Overloading means same method Name and Different arguments or parameters.

Example

public class ...

{

public int add(int x,int y)

{

.....

}

public float add(float x,float y)

{

....

}

}

  Was this answer useful?  Yes

Its a common mistake to assume that overloading is a kind of polymorphism in OOPS..
But its actually not..
However the definition is the same.. an entity existing in different forms is called polymorphism..
in Java, polymorphism is achieved with super class reference variable..


This means a subclass object exists in diffrent reference variables.i.e., the sub class reference variable can hold a reference to sub class object
as well as
the super class ref varibale can hold a ref to super class object...,

This is true ploymorphism..

eg: let A be super class of B

 B b=new B();
A a=b;

// this is correct polymorphism. an object is representable using its own reference variable or a super class reference variable...

source : khalid moghul  SCJP 1.4
Thanks:
Aravind

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions