Weather Forecast

Java Spring Components Language features Public New



Consider the following two classes:

public class WeatherForecastService {

    private Thermometer thermometer;

    public WeatherForecastService(Thermometer thermometer) {
        this.thermometer = thermometer;

    @Scheduled(fixedDelay = 10000)
    public void takeTemperatureMeasurement() {

public class FakeThermometer implements Thermometer {

    public int measure() { return 10; };

Supposing Spring uses component scanning to discover beans, select all of the statements that are correct.

Instantiation of WeatherForecastService will fail because Thermometer is an interface and not a class.
Instantiation of WeatherForecastService will fail, because only @Repository beans may be injected into @Service beans.
Automatic execution of takeTemperatureMeasurement() every 10 seconds can be enabled by annotating the Spring configuration class with @EnableScheduling.
Automatic execution of takeTemperatureMeasurement() every 10 seconds can be enabled by using <task:annotation-driven/> in XML configuration.
A new instance of the FakeThermometer class will be created each time the takeTemperatureMeasurement() method is executed.