By providing a clear separation between a method declaration and implementation, interfaces enable the addition of an abstraction layer to code. As a result, it becomes possible to have different implementations of a method based on specific conditions.
In the previous session, we learned how inheritance works in Salesforce.
By providing a clear separation between a method declaration and implementation, interfaces enable the addition of an abstraction layer to code. As a result, it becomes possible to have different implementations of a method based on specific conditions.
As an example, we can take from the Banks where every bank has its own interest for a different type of loans. Here is how the Apex Class will look like that is implementing the interface
Hands-On –
The class that implements the interface. To implement the interface, we need to use implements keywords