Initializing an online course catalog

Report a typo

We have a class that stores information about online courses. How can you modify this class to make the Spring container invoke custom destruction and initialization? Select all required options.

Java
class OnlineCourseCatalog implements DisposableBean {
    private final List<String> courses = Collections.synchronizedList(new ArrayList<>());

    public void init() throws Exception {
        courses.add("Java for everyone");
        courses.add("Spring Boot in Action 2022");
        courses.add("Improve your Agile skills");
    }

    @Override
    public void destroy() {
        courses.clear();
    }
}
Kotlin
class OnlineCourseCatalog : DisposableBean {
    private val courses: MutableList<String> = Collections.synchronizedList(ArrayList())
    
    fun init() {
        courses.add("Java for everyone")
        courses.add("Spring Boot in Action 2022")
        courses.add("Improve your Agile skills")
    }

    override fun destroy() {
        courses.clear()
    }
}
Select one or more options from the list
___

Create a free account to access the full topic