Marlabs interview question

Oops in java, collection, some logics