Pergunta de entrevista da empresa Tech Mahindra

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