Code Explanation:
Note:- Observers are subscribed to subject and have one to many relationships and whenever subject publishes observers gets notifications. It follows push based approach and whenever they have something they push to the observers.