Which is better setter or constructor injection?



Which is better setter or constructor injection?..

Answer / Nikunj Kumar

Neither setter nor constructor injection is inherently better. The choice depends on the specific needs of the application and design preferences. Setter injection allows for easier configuration but can lead to looser coupling, while constructor injection promotes stronger coupling but enforces dependencies at object creation.

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  


Is spring boot a microservice framework? : Spring Boot

1 Answers  


How do you define the scope of a bean?

1 Answers  


What are the different types of annotations in spring?

1 Answers  


What is @qualifier annotation in spring?

1 Answers  


What are the different components of a spring application?

1 Answers  


What is pointcut in spring?

1 Answers  


What is a framework in it?

1 Answers  


What is difference between hibernate and spring?

1 Answers  


What is difference between bean and pojo?

1 Answers  


Is singleton thread safe in spring?

1 Answers  


Explain the spring mvc framework.

1 Answers  


Categories