Core Java - Interview Questions and Answers for 'Factory method' | Search Interview Question -

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 'Factory method' - 1 question(s) found - Order By Newest

 Q1. What are the trade offs between public constructor and static final method ?Core Java
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

Related Questions

  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 are the advantages and disadvantages of Factory Design Pattern ?
  What is ThreadFactory ?
  How many SessionFactory and Session objects are created ?
  Which class provides the enumerated value for Bean Scope ?
 What is a factory design pattern ?
 Difference between Singleton and Factory Design Pattern ?

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: