MindGate Solutions interview question

Basic java