Core Java - Interview Questions and Answers for 'Private constructor' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

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

   



Core Java - Interview Questions and Answers for 'Private constructor' - 4 question(s) found - Order By Rating

 Q1. Can we instantiate the object of derived class if parent constructor is private ?Core Java
Ans. No

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

   Like         Discuss         Correct / Improve     constructor  private constructor


 Q2. Can a constructor have a private access specifier ?Core Java
Ans. Yes, declaring a constructor private means disabling the creation of object that way using new operator.

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

   Like         Discuss         Correct / Improve     constructor  private constructor


 Q3. Have you ever felt the need of keeping the constructor private ?Design
Ans. Yes, When either we don't want an object to be created ( class having all static elements and hence not required ) or object to be created using a static method or static block. One such example could be a situation when we would like app to load objects at start up and we would like to restrict new object creation by any request.

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

   Like         Discuss         Correct / Improve     private constructor  constructor


 Q4. Can we instantiate the object of derived class if parent constructor is protected ?Core Java
Ans. Yes, as protected constructor is accessible in sub class.

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

   Like         Discuss         Correct / Improve     java   oops   constructor   access specifier   protected   yes-no  private constructor


 Q5. How can we create objects if we make the constructor private ?Core Java
a. We can't create objects if constructor is private
b. We can only create objects if we follow singleton pattern
c. We can only create one object
d. We can create new object through static method or static block

Ans.d. We can create new object through static method or static block


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: