What is the difference between constructor injection and setter injection?



What is the difference between constructor injection and setter injection?..

Answer / Ankita Srivastava

"Constructor injection involves injecting dependencies through a project's constructor, ensuring that an object is properly initialized. Setter injection, on the other hand, involves setting properties of an object after its creation by using setter methods. Both techniques are used for dependency injection in Spring Framework but have different implications for object initialization and accessibility."n

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Spring Framework Interview Questions

What is the concept of dao? : Spring Boot

1 Answers  


Can we learn spring boot without spring? : Spring Boot

1 Answers  


what is default scope in spring?

1 Answers  


Why dependency injection is required?

1 Answers  


What is the scope of spring?

1 Answers  


What is @controller in spring boot?

1 Answers  


What is use of @configuration in spring?

1 Answers  


What is difference between java singleton and spring singleton?

1 Answers  


What is jdbc abstraction and dao module?

1 Answers  


What is a beanfactorypostprocessor and what is it used for?

1 Answers  


What is the scope of spring beans?

1 Answers  


What is @autowired in spring?

1 Answers  


Categories