Explain the difference between constructor and setter injection?

Spring Interview Questions Spring, Spring Core, Spring IoC Interview Questions in Spring Interview Questions . 3 years ago

  3   0   0   0   0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
  • In constructor injection, partial injection is not ALLOWED whereas it is allowed in setter injection.
  • The constructor injection doesn’t override the setter property whereas the same is not true for setter injection.
  • Constructor injection creates a NEW instance if any modification is done. The creation of a new instance is not possible in setter injection.
  • In case the BEAN has many properties, then constructor injection is preferred. If it has few properties, then setter injection is preferred.

Posted on 14 May 2022, this text provides information on Spring Interview Questions related to Spring, Spring Core, Spring IoC Interview Questions in Spring Interview Questions. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Tuteehub forum answer Answers

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.