What is the name?

Report a typo

You have the following class in your project:

package com.example.app;

@Component
public class Person {
    private String name;

    public Person() {}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

What will be printed to the console by the application runner below?

package com.example.app

@SpringBootApplication
public class ScopesTestApplication {

    public static void main(String[] args) {
        SpringApplication.run(ScopesTestApplication.class, args);
    }

    @Component
    public class Runner implements CommandLineRunner {

        private Person mary;
        private Person john;

        public Runner(Person mary, Person john) {
            this.mary = mary;
            this.john = john;
        }

        @Override
        public void run(String... args) {
            mary.setName("Mary");
            john.setName("John");
            System.out.println(mary.getName());
        }
    }

}
Enter a short text
___

Create a free account to access the full topic