What are constructors and Destructors in Java ?

Search Interview Questions

 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text


Interview Questions and Answers

 Q1. What are constructors and Destructors in Java ?Core Java
Ans. Constructors are used for initializing the object state once it is initialized and memory has been reserved for it.

Destructor is used to de-allocate memory allocated by objects.

There are no destructors in Java. Alternatively, Java provides Automatic garbage collection i.e automatically releasing the un-referenced memory.

  Sample Code for constructor

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     constructors  destructors     Asked in 2 Companies

Try 1 Question(s) Test

Related Questions

  Why every object constructor automatically call super() in Object before its own constructors?
  Can constructors be synchronized in Java ?
  Are constructors inherited? Can a subclass call the parent's class constructor? When?
  Which of the following is false about Constructors ?
  Which of the following cannot be marked static ?
  Can we overload constructors ?
 Is it advisable to set the member variables through constructors instead of setting them through setters ?
 Why doesn't Java even allow void return types for Constructors ?
 What is the use of constructors in Java ?

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: