Skip to main content

Spring Interview Questions


Inversion of Control

As the name implies Inversion of control means now we have inverted the control of creating the object from our own using new operator to container or framework. Now it’s the responsibility of container to create an object as required.

Dependency Injection

The technology that Spring is most identified with is the Dependency Injection (DI) flavor of Inversion of Control. The Inversion of Control (IoC) is a general concept, and it can be expressed in many ways. Dependency Injection is merely one concrete example of Inversion of Control.

When writing a complex Java application, application classes should be as independent as possible of other Java classes to increase the possibility to reuse these classes and to test them independently of other classes while unit testing. Dependency Injection helps in gluing these classes together and at the same time keeping them independent.

What is dependency injection exactly? Let's look at these two words separately. Here the dependency part translates into an association between two classes. For example, class A is dependent of class B. Now, let's look at the second part, injection. All this means is, class B will get injected into class A by the IoC.

Dependency injection can happen in the way of passing parameters to the constructor or by post-construction using setter methods.

Comments

Popular posts from this blog

OOPS concepts Tutorial

OOPS concepts Tutorial Summary: By the end of this tutorial "OOPS concepts Tutorial", you will understand the meaning of OOPS concepts. Three basic concepts of OOPS Abstraction Encapsulation Polymorphism 1. Abstraction     Abstraction means using the equipment (or code) without knowing the details of working. For example, you are using your mobile phone without knowing how a mobile operates internally. Just a click on a button connects to your friend. This is abstraction. That is, the details of mobile mechanism are abstracted. Similarly we use the code of somebody to get the functionality without knowing how the code is written or working. For example, you are using printf() function to write to the DOS prompt without the awareness of what the code of printf(). One of the ways of achieving abstraction is inheritance. Through inheritance a subclass can use the super class methods as if they belong to it without caring their implementation details. 2. Encapsula...

Basic Definitions

Basic Definitions Class :     A class is a blueprint or prototype from which objects are created.                                                            (or) A Class is a template or Blue print is used to bind or group the related data members along with its related functionalities                                                            (or)     A class is a prototype that defines the variables and the methods common to all objects of a certain kind. Member Functions operate upon the member variables of the class. Object :  Objects is instance of a class it contains state and behaviors, State is nothing but variables and beha...
Struts Actions Forward Action :          In Struts MVC model, you have to go through the Action Controller to get a new view page. In some cases, you really just need to get a specified JSP page only, it's so stupid to create an action controller class which just forward the pate to you.        ForwardAction acts as bridge from the current view and pages it link to.ForwardAction uses the RequestDispatcher to forward to a specified web resource.This allow you to link to an action instead of directly to a jsp.  Used of Forward Action :- The ForwardAction class is useful when you’re trying to integrate Struts into an existing application that uses Servlets to perform business logic functions.  ForwardAction used to forward a request to another resource in your application, such as a Servlet that already does business logic processing or even another JSP page. Include Action :         Includ...