Recall & Review
beginner
What does the
@Configuration annotation do in Spring Boot?It marks a class as a source of bean definitions. Spring reads this class to create and manage beans in the application context.Click to reveal answer
beginner
What is the purpose of the
@Bean annotation in a Spring Boot @Configuration class?It tells Spring that the method will return an object that should be registered as a bean in the application context.
Click to reveal answer
intermediate
How do
@Configuration and @Bean work together in Spring Boot?<code>@Configuration</code> marks the class as a bean factory. Inside it, methods annotated with <code>@Bean</code> create and return beans that Spring manages.Click to reveal answer
intermediate
Can a method annotated with
@Bean have parameters? What happens if it does?Yes, it can have parameters. Spring will automatically inject beans matching those parameter types when calling the method.
Click to reveal answer
intermediate
Why might you use
@Configuration and @Bean instead of @Component?Because
@Configuration allows you to define beans with custom logic inside methods, giving more control over bean creation than simple @Component classes.Click to reveal answer
What does the
@Configuration annotation indicate in Spring Boot?✗ Incorrect
@Configuration marks a class as a source of bean definitions.What does the
@Bean annotation do?✗ Incorrect
@Bean marks a method whose return value is managed as a bean.If a
@Bean method has parameters, what happens?✗ Incorrect
Spring injects beans matching the parameter types when calling the method.
Which annotation would you use to create a bean with custom setup logic?
✗ Incorrect
Using
@Bean inside a @Configuration class allows custom bean creation logic.What is the main difference between
@Component and @Configuration?✗ Incorrect
@Configuration classes can define multiple beans via methods.Explain how
@Configuration and @Bean work together in Spring Boot to create and manage beans.Think about a class that acts like a factory for objects.
You got /4 concepts.
Describe why you might choose to use
@Bean methods inside a @Configuration class instead of just using @Component on a class.Consider when you want to write code to create the bean yourself.
You got /4 concepts.