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. |
|
| |||||||||||
Core Java - Interview Questions and Answers for 'Private constructor' - 4 question(s) found - Order By Newest | |||||||||||
| |||||||||||
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 | |||||||||||
| |||||||||||
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 | |||||||||||
| |||||||||||
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 | |||||||||||
| |||||||||||
Ans. No | |||||||||||
Help us improve. Please let us know the company, where you were asked this question : | |||||||||||
Like Discuss Correct / Improve  constructor  private constructor | |||||||||||
| |||||||||||