1.

When a compiler can automatically generate a constructor if it is not defined then why is it considered that writing constructor for a class is a good practice? 

Answer»

When an object of the class is created a compiler can automatically generates a constructor if it is not defined. It is considered that writing constructor for a class is a good practice because constructor takes over very important duty of initialization of an object being created and relieves us from this task.



Discussion

No Comment Found

Related InterviewSolutions