Spring / Spring7 basics Interview questions
What is Inversion of Control in Spring?
Inversion of Control (IoC) is the design principle where an object no longer creates or looks up its own collaborators; instead, control over object creation and wiring is handed to a container. In a plain Java program, a class typically instantiates the objects it depends on with new. Under IoC, that responsibility moves outward to the Spring container.
Spring implements IoC through its IoC container, represented by the BeanFactory and ApplicationContext interfaces, which read configuration (annotations, Java config, or XML) and construct, configure, and manage the lifecycle of every bean. The main benefit is loose coupling: classes depend on abstractions rather than concrete implementations, which makes code easier to test, swap, and extend.
More Related questions...