Interface

An Interface is a declaration of a set of Methods with no information given about the implementation of those methods. Interfaces are used to define common functionality that can be used by different classes. Interfaces are implemented in classes by listing the interface name in the definition part of the class.

CLASS customer DEFINITION.
Public Section.
INTERFACES <interface_name>.
ENDCLASS.

An interface can be implemented publicly. The methods defined in the interface are implemented in the class. All methods that are defined in the interfaces must be present in the implementing class.

Much like a class, an interface defines methods. However, unlike a class, an interface never implements methods; instead, classes that implement the interface provide the implementation to the methods defined by the interface.

An interface can be accessed using an object reference as long as that objects class implements the interface. This is done using the interface resolution operator ‘~’:
<object_name>-><interface_name>~<method_name>.

Comments