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. Both are creational design patterns.|
Singleton is used when we would like to reuse an object if object is not supposed to hold request or thread specific information. Inversely Prototype is used in situations where we would like to reuse the object information but the request / thread may require it own data to be persisted.
In short, Singleton is used in situations where we can live with single object being shared across multiple requests or threads whereas Prototype is used when we need duplicate copies of objects.
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  design pattern  singleton  prototype  creational design pattrn Asked in 7 Companies expert|
Try 1 Question(s) Test
|What is the difference between Singleton and Prototype Bean scope in Spring ?|
|When should we use prototype scope and singleton scope for beans ?|
|Does it make sense to clone an object which is supposed to be immutable ?|
|What is a prototype design pattern ?|
|Can we use Prototype Bean scope with Autowiring ?|