Pregunta de entrevista de Maventic

A java program was given to solve.