Pregunta de entrevista de Tech Mahindra

basics of Java Programming, to write code for the given problem, some logical questions