Morgan Stanley Interview Question

question about design pattern and some logical questions