Tech Mahindra interview question

Java basics