Spring Boot Dependency Injection

    Question 1CORE SPRING BOOT - Dependency Injection Concept

    What is the main purpose of Dependency Injection (DI) in Spring Boot?

    Question 2CORE SPRING BOOT - Constructor Injection

    Which of the following best describes constructor-based dependency injection?

    Question 3CORE SPRING BOOT - Setter Injection

    Which of the following best describes setter-based dependency injection?

    Question 4CORE SPRING BOOT - Field Injection

    What is a key drawback of field injection using @Autowired directly on fields?

    Question 5CORE SPRING BOOT - Constructor Injection Example

    What will happen when this Spring Boot code runs?

    @Component public class ServiceA {} @Component public class ServiceB { private final ServiceA serviceA; @Autowired public ServiceB(ServiceA serviceA) { this.serviceA = serviceA; } }

    Question 6CORE SPRING BOOT - Setter Injection Example

    In the following code, how is ServiceA injected into ServiceB?

    @Component public class ServiceA {} @Component public class ServiceB { private ServiceA serviceA; @Autowired public void setServiceA(ServiceA serviceA) { this.serviceA = serviceA; } }

    Question 7CORE SPRING BOOT - Field Injection Example

    Identify the injection type in the following code:

    @Component public class ServiceA {} @Component public class ServiceB { @Autowired private ServiceA serviceA; }

    Question 8CORE SPRING BOOT - Benefits of Constructor Injection

    Which of the following is a key advantage of constructor injection over setter or field injection?

    Question 9CORE SPRING BOOT - Optional Dependencies

    How can you mark a dependency as optional in Spring Boot DI?

    Question 10CORE SPRING BOOT - Circular Dependency Handling

    Which DI type is least prone to circular dependency issues in Spring Boot?