Persistent Systems Interview Question

Factory design patterns scenario and write the code.