J.P. Morgan interview question

Coding assessment related to java