A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Spring Framework Interview Question

What is IOC?

IOC stands for Inversion of Control (IOC). Spring framework provides this feature in Java that rather than creating an object from our application code, we are creating and instantiating object from spring container and that these phenomena are called IOC. IOC is also known as dependency injection.

What is Dependency Injection(DI)?

As we know about spring container is a very lightweight container in java, which is known as Spring core container used for dependency injection(DI). This container helps you to inject required objects into other objects. So that it results in a design pattern in which java classes are not hard-coded.

Why is DI also named an IOC?
Since, It’s a process whereby objects define their dependencies, that is, the other objects they work with, only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. The container then injects those dependencies when it creates the bean. This process is fundamentally the inverse, hence the name inversion of control(IOC).

What are the packages in spring framework used for spring IOC container?

The two packages are used to create an IOC container: -
1.    org.springframework.beans 
2.    org.springframework.context

The BeanFactory interface provides an advanced configuration mechanism capable of managing any type of object.
ApplicationContext is a sub-interface of BeanFactory and it adds easier integration with Spring’s AOP feature; message resource handling(for use in internationalization), event publication and application-layer specific context such as the WebApplicationContext for use in web application.

What are Beans in spring?

In Spring, the objects that form the backbone of your application and that are managed by the spring IOC container are called beans.
A bean is an object that is instantiated, assembled and otherwise managed by a Spring IOC container.

Who is responsible for instantiation, configuration, and assembling of beans (object)?

The interface org.springframework.context.ApplicationContextrepresents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans.

How does Spring Container work with Spring-configuration metadata?