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.
|Interview Questions and Answers|
|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
|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 ?|