Interfaces and Polymorphism
Task
Implement an interface and demonstrate polymorphism using different class implementations.
Write Your ABAP Code
Loading...
📥 Sample Input & Output
Vehicle Type: Car Output: Driving a car
💡 Hint
Program to an interface, not to a concrete class.
✅ View Reference Solution
INTERFACE lif_vehicle.
METHODS drive RETURNING VALUE(rv_text) TYPE string.
ENDINTERFACE.
CLASS lcl_car DEFINITION.
PUBLIC SECTION.
INTERFACES lif_vehicle.
ENDCLASS.
CLASS lcl_car IMPLEMENTATION.
METHOD lif_vehicle~drive.
rv_text = 'Driving a car'.
ENDMETHOD.
ENDCLASS.