Leyton interview question

Case exercice abt java & scala