What can an ABAP interface contain, how does a class implement it, and what do ALIASES, nested interfaces and DEFAULT IGNORE or DEFAULT FAIL give you?
Say your answer out loud first.
Practise another way
An interface declares public components without implementation: methods, static methods, attributes, constants, types and events, but no constructor and no visibility sections. A class lists it with INTERFACES in its public section and must implement every method, addressed as intf~method.
ALIASES gives a short name, an interface can include other interfaces, and DEFAULT IGNORE or DEFAULT FAIL make a method optional to implement. Callers then hold an interface reference, which gives polymorphism and easy test doubles.
Contents: METHODS, CLASS-METHODS, DATA, CLASS-DATA, CONSTANTS, TYPES, EVENTS. All components are public; there are no visibility sections, no implementation part and no constructor. You cannot instantiate an interface.
Implementing: INTERFACES lif_x. goes in the class's public section. The class implements each method as METHOD lif_x~meth. A class can implement many interfaces, but each interface only once in an inheritance tree.
Callers address components with the interface component selector ~, or better, through an interface reference variable (DATA reader TYPE REF TO lif_reader), which can point to any object whose class implements the interface.
INTERFACE lif_reader.
TYPES tt_names TYPE STANDARD TABLE OF string WITH EMPTY KEY.
METHODS read_all RETURNING VALUE(result) TYPE tt_names.
METHODS refresh DEFAULT IGNORE. " optional to implement
ENDINTERFACE.
INTERFACE lif_cached_reader.
INTERFACES lif_reader. " includes lif_reader
METHODS hit_rate RETURNING VALUE(result) TYPE decfloat34.
ENDINTERFACE.
CLASS lcl_customer_reader DEFINITION FINAL.
PUBLIC SECTION.
INTERFACES lif_cached_reader.
ALIASES read_all FOR lif_reader~read_all.
ENDCLASS.
CLASS lcl_customer_reader IMPLEMENTATION.
METHOD lif_reader~read_all.
result = VALUE #( ( `ACME` ) ( `Globex` ) ).
ENDMETHOD.
METHOD lif_cached_reader~hit_rate.
result = 1.
ENDMETHOD.
ENDCLASS.
Useful additions
ALIASES name FOR intf~comp: a short name inside the class and for callers using a class reference.- Nested (component) interfaces: an interface can include others with
INTERFACES; an implementing class must implement all of them. DEFAULT IGNORE/DEFAULT FAILon an interface method: implementing it becomes optional. If an unimplemented method is called, IGNORE behaves as if the method were empty, FAIL raisesCX_SY_DYN_CALL_ILLEGAL_METHOD. This lets an interface grow without breaking every implementer.- On the class side:
INTERFACES ... ABSTRACT METHODS(in an abstract class),FINAL METHODS,ALL METHODS ABSTRACT|FINAL, andDATA VALUESfor start values of interface attributes.
Design rules from SAP's Clean ABAP guide
- Public instance methods should be part of an interface; it decouples callers and makes mocking simple.
- Interfaces share definitions; abstract classes share implementation. Decide on the interface first, then whether an abstract class should help implement it.
- Do not use an interface just as a bag of constants; prefer an
ENUMor a constants class.
Lists what an interface can and cannot contain, shows INTERFACES and intf~meth, and knows ALIASES, component interfaces and DEFAULT IGNORE/FAIL.
Says 'an interface is like an abstract class with only abstract methods' and cannot write the syntax.
Saying ABAP interfaces cannot have attributes or events. They can declare attributes, constants, types and events; they only lack implementations, visibility sections and constructors.
- What happens when you call a DEFAULT FAIL method that is not implemented?
- Can an interface have a constructor or private components?
- Can a subclass implement an interface its superclass already implements?
- Why should public instance methods be in an interface?
1 candidate write-up, 3 official pages and 3 prep guides. Confidence: high. Checked 1 Dec 2026.
- Prep guide Describes the round.
- Prep guide Describes the round.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.
- Official page Backs the answer.
- Candidate write-up Gives the question.