Tavant interview question

Core Java programs for one of the scenarios