Getting beans practice

Report a typo

You have the following beans in your configuration class:

@Configuration
public class Config {

    @Bean
    public Product productMilk() {
        return new Product("milk");
    }

    @Bean 
    public Product productCheese() { 
        return new Product("cheese");
    }
}

Here is the Application class of your project:

public class Application {

    public static void main(String[] args) {
        var context = new AnnotationConfigApplicationContext(Config.class);
        System.out.println(Arrays.toString(context.getBeanDefinitionNames()));
    }
}

How can you get the productMilk bean in the Application class? Choose all possible options.

Select one or more options from the list
___

Create a free account to access the full topic