Google Search - Blog...........

ABAP - OOPS : Use Of FINAL Methods From Interface In Method Programming.

report ysubdel .

interface i1 .
methods : m1 ,
m2 .
endinterface.

class c1 definition.
public section.
interfaces : I1 final methods m2 .
endclass.

class c1 implementation.
method i1~m1.
write:/5 'I am m1 in c1'.
endmethod.
method i1~m2.
write:/5 'I am m2 in c1'.
endmethod.
endclass.

class c2 definition inheriting from c1.
public section.
methods : i1~m1 redefinition .
endclass.

class c2 implementation.
method : i1~m1.
write:/5 'I am m1 in c2'.
endmethod.
endclass.

start-of-selection.
data : oref1 type ref to c1,
oref2 type ref to c2 .
create object : oref1 , oref2.
call method : oref1->i1~m1 , “ Output : I am m1 in c1
oref2->i1~m1 , “ Output : I am m1 in c2
oref1->i1~m2 , “ Output : I am m2 in c1
oref2->i1~m2 . “ Output : I am m2 in c1


Output:

I am m1 in c1
I am m1 in c2
I am m2 in c1
I am m2 in c1

No comments:

Post a Comment