Nimmetry interview question

Java concepts