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. Public constructor is simple and easy as it's the default way of object creation. So there are no additional coding overheads as compiler provides the default constructor if none is provided by coder.|
With static final methods, it facilitates loose coupling by segregating the responsibility of object creation to a separate method. Validation can be done on the constructor arguments before calling it. Moreover if any adaption on the arguments is required that can achieved easily with factory method.On the flip side, there is coding overhead and additional method call.
Sample Code for constructor
Sample Code for factory
|Help us improve. Please let us know the company, where you were asked this question :|
|Like Discuss Correct / Improve  constructor  factory design pattern  factory method|
|Difference between Factory and Abstract Factory Design Pattern ?|
|Difference between Factory and Builder Design Pattern ?|
|Difference between Factory and Strategy Design Pattern ?|
| Please specify in what sequence the objects of following classes will be created ?|
Session , SessionFactory, Query , Configuration
|What is ThreadFactory ?|
|How many SessionFactory and Session objects are created ?|
|Which class provides the enumerated value for Bean Scope ?|
|What are the advantages and disadvantages of Factory Design Pattern ?|
|What is a factory design pattern ?|
|Difference between Singleton and Factory Design Pattern ?|