Explain the four pillars of object-oriented programming with one real business example in ABAP, not textbook definitions.
Say your answer out loud first.
Practise another way
Take payment fees. Abstraction: callers only know an interface lif_payment with a method fee. Encapsulation: each class keeps its rates private, so nobody changes them from outside. Inheritance: a corporate card class inherits from the card class and redefines only the fee rule.
Polymorphism: the code loops over a table of lif_payment references and calls fee, and the runtime picks the right implementation for each object. Adding a new payment type means a new class, not editing the loop.
Interviewers ask for an example because definitions are easy to memorise. Use one small business case and map each pillar to an ABAP construct.
Abstraction means callers depend on what something does, not how. In ABAP that is an interface (or an abstract class).
Encapsulation means state is hidden behind methods. Visibility sections do it: PRIVATE SECTION for rates and internals, PUBLIC SECTION only for the methods callers need.
Inheritance means a subclass takes over all components of its superclass (INHERITING FROM) and can add or redefine methods. ABAP allows one direct superclass only.
Polymorphism means one call through a reference of the interface or superclass type runs the implementation of the object's actual class.
INTERFACE lif_payment.
METHODS fee IMPORTING amount TYPE decfloat34 RETURNING VALUE(result) TYPE decfloat34.
ENDINTERFACE.
CLASS lcl_card DEFINITION.
PUBLIC SECTION.
INTERFACES lif_payment.
ENDCLASS.
CLASS lcl_card IMPLEMENTATION.
METHOD lif_payment~fee.
result = amount * '0.02'.
ENDMETHOD.
ENDCLASS.
CLASS lcl_corporate_card DEFINITION INHERITING FROM lcl_card FINAL.
PUBLIC SECTION.
METHODS lif_payment~fee REDEFINITION.
ENDCLASS.
CLASS lcl_corporate_card IMPLEMENTATION.
METHOD lif_payment~fee.
result = super->lif_payment~fee( amount ) / 2.
ENDMETHOD.
ENDCLASS.
DATA payments TYPE STANDARD TABLE OF REF TO lif_payment WITH EMPTY KEY.
payments = VALUE #( ( NEW lcl_card( ) ) ( NEW lcl_corporate_card( ) ) ).
DATA(fees) = VALUE string_table( FOR p IN payments ( |{ p->fee( 1000 ) }| ) ). " 20, 10
How to tell it in the interview
- Name the construct for each pillar: interface, visibility section,
INHERITING FROMwithREDEFINITION, and a reference whose static type is general while the dynamic type is specific. - Say why it pays off: a new payment type (a wallet, say) is a new class that implements
lif_payment; the loop does not change. - Add one honest caveat: inheritance is the pillar to use most carefully. SAP's Clean ABAP guide prefers composition and interfaces, and asks for classes to be
FINALunless they are designed for inheritance.
The same ideas appear in modern SAP code: RAP behavior pools are classes, released APIs are mostly interfaces and classes, and ABAP Unit test doubles depend on polymorphism.
Uses one business example and names the exact ABAP construct for each pillar, with a short code sketch and the benefit for change.
Recites four definitions from another language (Java examples, 'animal makes a sound') with no ABAP syntax.
Mixing up abstraction and encapsulation: abstraction is about the contract callers depend on, encapsulation is about hiding state behind that contract.
- Can you have polymorphism without inheritance in ABAP?
- Where does encapsulation break if you make attributes public?
- Why does Clean ABAP warn against deep inheritance trees?
1 candidate write-up, 2 official pages and 5 prep guides. Confidence: high. Checked 1 Dec 2026.
- Prep guide Describes the round.
- Candidate write-up Gives the question.
- Prep guide Gives the question.
- Prep guide Describes the round.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.