Accenture interview question

Java coding