Interface : An interface is not a class. It is an entity which can’t have implementation. An interface can only contain empty method declaration and components. Interface components are always public. We can later change the visibility of the components within the implementing class using the ALIASES.
Abstract Class : Abstract class is a special kind of class which can’t be instantiated. We can only instantiate the subclasses of the Abstract class if they are not abstract. Abstract class should at least contain one abstract method. Abstract methods are methods without any implementation – only a declaration. We can certainly define the variables referencing to Abstract class and instantiate with specific subclass at runtime.
Differences :
Abstract Class : Abstract class is a special kind of class which can’t be instantiated. We can only instantiate the subclasses of the Abstract class if they are not abstract. Abstract class should at least contain one abstract method. Abstract methods are methods without any implementation – only a declaration. We can certainly define the variables referencing to Abstract class and instantiate with specific subclass at runtime.
Differences :
- Multiple Inheritance:We can achieve multiple inheritance using Interfaces. Since ABAP doesn’t support more than one Super class, we can have only one abstract class as Super class.
- New Functionality:If we add a new method in the Interface, all the implementing classes have to implement this method. If we don’t implement the method, it would result into Run-time error. For Abstract class, if we add a non-abstract method, its not required to redefine that in each and every inherited class.
- Visibility:All interface components are PUBLIC by default. For Abstract class, we can set the visibility of each component.