Hi team,
I do research and interface class and what I understood…
An interface class must have method without implementing itself.
For example -
Base class -
public interface CustomerNotification
{
void sendNotification(str message);
}
Derived class -
public class EmailNotification implements CustomerNotification
{
public void sendNotification(str message)
{
info(strFmt("Email sent: %1", message));
}
}
public class SmsNotification implements CustomerNotification
{
public void sendNotification(str message)
{
info(strFmt("SMS sent: %1", message));
}
}
Suppose the business may change the notification mechanism depending on the customer: for example
Customer A → Email
Customer B → SMS
So, here we can use interface to acheive this.
Am I correct?
Pls advise, thanks

Report
All responses (
Answers (