Notification System in Java: Explanation & Practice
Create notification type hierarchy
Problem summary
Create Notification interface with Email, SMS, Push implementations.
Starter code
// interface Notifiable: send(String message)
// EmailNotification: sends via email
// SMSNotification: sends via SMS
// PushNotification: sends via push
public class Main {
public static void main(String[] args) {
// Send notification via each channel
// Print: [Type] Sent: <message>
}
}Expected output and test cases
- Email notification
[Email] Sent: Hello
- SMS notification
[SMS] Sent: Alert
- Push notification
[Push] Sent: Update
Hints
- Interface defines send() contract
- Each class formats output differently
- Use polymorphism to call correct send()
Related Inheritance exercises
- Practice Simple Decorator in Java
- Practice Media Library System in Java
- Practice Calculator with Operations in Java
Practice all Inheritance exercises · Run this idea in the Java compiler