Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

method-urgent

Former Member
0 Kudos
122

How can we differ two methods irrespective of the method names.That means suppose in a class there are two methods with same names but with different parameters which are of differernt data types then the 2 methods will be different or they will be same and exhibiting the phenomenon of polymorphism.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
82

Dear Sandeep,

In ABAP, method name are unique i.e., we can not have 2 methods with same name but with different arguments. It is possible other OO language like C++ but not in ABAP.

Using inheritance we can have same method name of base class but here we have to redefine in sub class using REDEFINITION.

Regards

Kesava

3 REPLIES 3

Former Member
0 Kudos
83

Dear Sandeep,

In ABAP, method name are unique i.e., we can not have 2 methods with same name but with different arguments. It is possible other OO language like C++ but not in ABAP.

Using inheritance we can have same method name of base class but here we have to redefine in sub class using REDEFINITION.

Regards

Kesava

Former Member
0 Kudos
82

Hi Sandeep,

This question actually answers your first question as well.

We can not have methods with same name in a class in ABAP. I mean there is no method overloading in ABAP. Then you may ask me how polymorphism is possible ??. You can redefine a method in inherited classes. I mean method overriding. Now one method is existing with the same name but with 2 different implementations. Hence its poly morphism. Now once again the question is which implementation will be called ?? It depends upon the object which is calling the method. Depending the object which is calling the method implementation is called. <b>So Poly morphism in ABAP is achieved through method over riding.</b>

I have seen your different questions. Great .. Keep going in OOABAP. Its sexy.

If i find time i'll give you code samples as well.

Reward points if useful,

Aleem.

lokesh_kamana
Active Contributor
0 Kudos
82

Hi Sandeep,

the only answer i can say to your question is in ABAP.

we dont have 2 methods with the same name in a single class.

however this is possible when we inherit the class->another class and write Redefinition for that method.

first checking will be done with method names only.

After that only parameters come into picture when we execute the method.

if you want more clerification.

so that i can answer you.

WITH REGARDS,

Lokesh@eds