Morgan Stanley Interview Question

Correct the Java code below