Pregunta de entrevista de Tech Mahindra

What is the necessity of having a constructor in Java code?