Spring Framework


Spring is the facto enterprise server and integration tool in Investment banks. This IOC based development and hosting service become very popular for java based service development. We should be clear on basic concept and usage of spring for any java based technical interview. The Spring Framework is an open source application framework and Inversion of control container for the Java platform. This framework reduce the cost and burden of application server and provided more flexibility to developers. Spring core module details.

    The Spring Framework comprises several modules that provide a range of services:
    •  Inversion of Control container: configuration of application components and lifecycle management of Java objects, done mainly via Dependency Injection
    • Aspect-oriented programming: enables implementation of cross-cutting routines
    •  Data access: working with relational database management systems on the Java platform using JDBC and object-relational mapping tools and with NoSQL databases
    •  Transaction management: unifies several transaction management APIs and coordinates transactions for Java objects
    • Model-view-controller: an HTTP- and servlet-based framework providing hooks for extension and customization for web applications and RESTful web services.
    • Remote Access framework: configurative RPC-style export and import of Java objects over networks supporting RMI, CORBA and HTTP-based protocols including web services (SOAP)
    •  Convention-over-configuration: a rapid application development solution for Spring-based enterprise applications is offered in the Spring Roo module
    • Batch processing: a framework for high-volume processing featuring reusable functions including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management
    • Authentication and authorization: configurable security processes that support a range of standards, protocols, tools and practices via the Spring Security sub-project (formerly Acegi Security System for Spring).
    • Remote Management: configurative exposure and management of Java objects for local or remote configuration via JMX
    • Messaging: configurative registration of message listener objects for transparent message-consumption from message queues via JMS, improvement of message sending over standard JMS APIs
    • Testing: support classes for writing unit tests and integration tests.


    Spring Interview Questions

    1) What is Spring Framework?
       Spring is a lightweight inversion of control and aspect-oriented container framework. Spring Framework’s contribution towards java community is immense and spring community is the largest and most innovative community by size. They have numerous projects under their portfolio and have their own spring dm server for running spring applications. This community is acquired by VMWare, a leading cloud compting company for enabling the java application in the cloud by using spring stacks. If you are looking to read more about the spring framework and its products, please read in their official site Spring Source.

    2) Explain Spring?
    • Lightweight : Spring is lightweight when it comes to size and transparency. The basic version of spring framework is around 1MB. And the processing overhead is also very negligible.
    • Inversion of control (IoC) : Loose coupling is achieved in spring using the technique Inversion of Control. The objects give their dependencies instead of creating or looking for dependent objects.
    • Aspect oriented (AOP) : Spring supports Aspect oriented programming and enables cohesive development by separating application business logic from system services.
    • Container : Spring contains and manages the life cycle and configuration of application objects.
    • Framework : Spring provides most of the intra functionality leaving rest of the coding to the developer.


    3) What are the different modules in Spring framework?
    The Core container module
    • Application context module
    • AOP module (Aspect Oriented Programming)
    • JDBC abstraction and DAO module
    • O/R mapping integration module (Object/Relational)
    • Web module
    • MVC framework module

    4) What is the structure of Spring framework?
           DAO
           ORM
           AOP
           JEE
          CORE
          WEB

    5) What is the Core container module?
      This module is provides the fundamental functionality of the spring framework. In this module BeanFactory is the heart of any spring-based application. The entire framework was built on the top of this module. This module makes the Spring container.

    6) What is Application context module?
      The Application context module makes spring a framework. This module extends the concept of BeanFactory, providing support for internationalization (I18N) messages, application lifecycle events, and validation. This module also supplies many enterprise services such JNDI access, EJB integration, remoting, and scheduling. It also provides support to other framework.

    7) What is AOP module?
    The AOP module is used for developing aspects for our Spring-enabled application. Much of the support has been provided by the AOP Alliance in order to ensure the interoperability between Spring and other AOP frameworks. This module also introduces metadata programming to Spring. Using Spring’s metadata support, we will be able to add annotations to our source code that instruct Spring on where and how to apply aspects.

    8) What is JDBC abstraction and DAO module?
    Using this module we can keep up the database code clean and simple, and prevent problems that result from a failure to close database resources. A new layer of meaningful exceptions on top of the error messages given by several database servers is bought in this module. In addition, this module uses Spring’s AOP module to provide transaction management services for objects in a Spring application.

    9) What are object/relational mapping integration module?
    Spring also supports for using of an object/relational mapping (ORM) tool over straight JDBC by providing the ORM module. Spring provide support to tie into several popular ORM frameworks, including Hibernate, JDO, and iBATIS SQL Maps. Spring’s transaction management supports each of these ORM frameworks as well as JDBC.

    10) What is web module?
    This module is built on the application context module, providing a context that is appropriate for web-based applications. This module also contains support for several web-oriented tasks such as transparently handling multipart requests for file uploads and programmatic binding of request parameters to your business objects. It also contains integration support with Jakarta Struts.

    11) What is Spring Mvc?
    Spring comes with a full-featured MVC framework for building web applications. Although Spring can easily be integrated with other MVC frameworks, such as Struts, Spring’s MVC framework uses IoC to provide for a clean separation of controller logic from business objects. It also allows you to decoratively bind request parameters to your business objects. It also can take advantage of any of Spring’s other services, such as I18N messaging and validation.

    12) What is a BeanFactory?
    A BeanFactory is an implementation of the factory pattern that applies Inversion of Control to separate the application’s configuration and dependencies from the actual application code.

    13) What is AOP Alliance?
    AOP Alliance is an open-source project whose goal is to promote adoption of AOP and interoperability among different AOP implementations by defining a common set of interfaces and components. We can use Spring AOP module or we can integrate services with AspectJ. We can only advice method join points using Spring AOP.
      Spring AOP works on concept of proxies using JDK dynamic proxies or CGLIB. 

    14) What is Spring configuration file?
    Spring configuration file is an XML file. This file contains the classes information and describes how these classes are configured and introduced to each other.

    15) What does a simple spring application contain?
    These applications are like any Java application. They are made up of several classes, each performing a specific purpose within the application. But these classes are configured and introduced to each other through an XML file. This XML file describes how to configure the classes, known as the Spring configuration file.

    16) What is XMLBeanFactory?
    BeanFactory has many implementations in Spring. But one of the most useful one is org.springframework.beans.factory.xml.XmlBeanFactory, which loads its beans based on the definitions contained in an XML file. To create an XmlBeanFactory, pass a java.io.InputStream to the constructor. The InputStream will provide the XML to the factory. For example, the following code snippet uses a java.io.FileInputStream to provide a bean definition XML file to XmlBeanFactory.


     BeanFactory factory = new XmlBeanFactory(
           new FileInputStream("beans.xml"));
    To retrieve the bean from a BeanFactory, call the getBean() method by passing the name of the bean you want to retrieve.

    MyBean myBean = (MyBean) factory.getBean("myBean");

    17) What are important ApplicationContext implementations in spring framework?
    • ClassPathXmlApplicationContext – This context loads a context definition from an XML file located in the class path, treating context definition files as class path resources.
    • FileSystemXmlApplicationContext – This context loads a context definition from an XML file in the filesystem.
    • XmlWebApplicationContext – This context loads the context definitions from an XML file contained within a web application.
    18) Explain Bean lifecycle in Spring framework?
    The spring container finds the bean’s definition from the XML file and instantiates the bean.
    1. Using the dependency injection, spring populates all of the properties as specified in the bean definition.
    2. If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.
    3. If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of itself.
    4. If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called.
    5. If an init-method is specified for the bean, it will be called.
    6. Finally, if there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.
    19) What is bean wiring?
    Combining together beans within the Spring container is known as bean wiring or wiring. When wiring beans, you should tell the container what beans are needed and how the container should use dependency injection to tie them together.

    20) How do add a bean in spring application?
    <!DOCTYPE beans PUBLIC    "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd">
       <bean name="/helloWorld" class="test.HelloWorldController">  

    In the bean tag the id attribute specifies the bean name and the class attribute specifies the fully qualified class name.

    21) What are singleton beans and how can you create prototype beans?
    Beans defined in spring framework are singleton beans. There is an attribute in bean tag named ‘singleton’ if specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean. By default it is set to true. So, all the beans in spring framework are by default singleton beans.
      < bean class="com.act.Foo"    singleton="false">


    22) What are the important beans lifecycle methods?
    There are two important bean lifecycle methods. The first one is setup which is called when the bean is loaded in to the container. The second method is the teardown method which is called when the bean is unloaded from the container.

    23) How can you override beans default lifecycle methods?
    The bean tag has two more important attributes with which you can define your own custom initialization and destroy methods. Here I have shown a small demonstration. Two new methods fooSetup and fooTeardown are to be added to your Foo class.




      class="com.act.Foo"
         init-method="fooSetup" destroy="fooTeardown">;
    24) What are Inner Beans?
    When wiring beans, if a bean element is embedded to a property tag directly, then that bean is said to the Inner Bean. The drawback of this bean is that it cannot be reused anywhere else.

    25) What are the different types of bean injections?
    There are two types of bean injections.
    1. By setter
    2. By constructor


  • We are covering here -'Java garbage collection interview questions' or 'Java memory interview questions' in d...
  • ' Java database questions ' or ' Database interview questions for java developer ' is covered in this blog. All ent...
  • Java Concurrency interview question - In year 2004 when technology gurus said innovation in Java is gone down and Sun Microsystems [Now Or...
  • 'Java investment bank interview' generally contains 'Java Design Pattern' questions. If you want to be a professional Java ...
  • 49 comments:

    1. very nice. for java examples, visit java2novice.com site

      ReplyDelete
    2. It is really a great work and the way in which u r sharing the knowledge is excellent.
      Thanks for helping me to understand basic concepts. As a beginner in java programming your post help me a lot.Thanks for your informative article.java training in chennai

      ReplyDelete
    3. Thanks for sharing the very useful info about Spring and please keep updating........

      ReplyDelete
    4. Thanks a lot! You made a new blog entry to answer my question; I really appreciate your time and effort.Its very valuable to me thanku so much for this interesting blog
      core java training in chennai |
      best java training institute in chennai

      ReplyDelete
    5. This information you provided in the blog that is really unique I love it!! Thanks for sharing such a great blog Keep posting..
      Spring Interview Questions and Answers

      ReplyDelete
    6. Nice Post! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep sharing… Full Stack Training in Hyderabad

      ReplyDelete
    7. Nice article.. very interesting and useful, keep sharing!!
      DevOps Online Training

      ReplyDelete
    8. I prefer to study this kind of material. Nicely written information in this post, the quality of content is fine and the conclusion is lovely. Things are very open and intensely clear explanation of issues
      Best Spring Classroom Training Institute
      Best Devops Classroom Training Institute
      Best Corejava Classroom Training Institute
      Best Advanced Classroom Training Institute

      ReplyDelete
    9. Very nice collection of courses for managers. Keep sharing more courses for other streams also. Thanks.

      Online fitness equipments
      website designing company in gurgaon
      Best Hotels in mussoorie

      ReplyDelete
    10. I am really happy with your blog because your article is very unique and powerful for new reader.prefer to study this kind of material. Nicely written information in this post,the quality of content is fine and the conclusion is lovely. Things are very open and intensely clear explanation of issues.
      https://www.acte.in/php-training-in-chennai
      https://www.acte.in/machine-learning-training-in-chennai
      https://www.acte.in/iot-training-in-chennai
      https://www.acte.in/blockchain-training-in-chennai
      https://www.acte.in/openstack-training-in-chennai


      ReplyDelete
    11. This is the exact information I am been searching for, Thanks for sharing the required information with the clear update and required points. To appreciate this I like to share some useful information I’ll bookmark your weblog and check again here regularly. I am quite sure I will learn much new stuff right here!
      Salesforce Training in Chennai | Certification | Online Course | Salesforce Training in Bangalore | Certification | Online Course | Salesforce Training in Hyderabad | Certification | Online Course | Salesforce Training in Pune | Certification | Online Course | Salesforce Online Training | Salesforce Training

      ReplyDelete
    12. Good and very well written blog this blog has excellent knowledgeable content and has been immensely helpful and understanding various concepts and theory
      java certification training
      java course
      java training
      best java course

      ReplyDelete
    13. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
      Java Training in Chennai

      Java Training in Velachery

      Java Training in Tambaram

      Java Training in Porur

      Java Training in OMR

      Java Training in Annanagar



      ReplyDelete

    14. Thank you for sharing wonderful information with us to get some idea about it.
      Mulesoft Online Training in Hyderabad
      Mulesoft Training in Hyderabad

      ReplyDelete
    15. Mendixis a RAD tool that lets you create applications quickly. This is possible because Mendix is a complete development platform, providing you with the tools and services to quickly build, test, and deploy

      ReplyDelete
    16. Helpful shared content.
      Please take a look to our website.
      We provide very cheap rate reseller hosting and website hosting services.
      Please visit our website and let us know in our comment box.
      www.microcen.com

      ReplyDelete
    17. Many email users are facing a common problem i.e. forgetting the password of their email account. If any Yahoo email user wants to know about Yahoo mail forgot password and security question. If you have any problem with your Yahoo account or you cannot head your Yahoo account after many attempts then you can go to Yahoo mail forgot password and security question

      How Yahoo mail forgot password and security question


      How Yahoo account recovery phone number

      How To Recover Yahoo Mail Account

      Cannot Login To Yahoo Mail


      Yahoo mail Login USal

      ReplyDelete
    18. We analyse and Compare Energy Suppliers to find you the right deal on gas and electricity prices and then manage the whole process of energy Switching for you
      Due to the fixed energy rates, the third party energy suppliers can become your first choice.
      How do I switch energy supplier for my business, As a customer, you can get the fixed-rate energy plans. It doesn't matter what the current market rate of electricity is, the customers will pay only the set price.


      compare gas and electric


      Before you compare gas and electricity, this becomes a big benefit through third-party energy suppliers.

      At RT Utilities we provide cheap gas and electricity rates You can expect to get flexible energy agreements with third-party energy suppliers. If you compare energy prices and bills, it might be easy to know how to reduce them. In the same situation, one should always know that third party energy suppliers have a limited geographic range. Hence, there are some drawbacks you can get with these energy suppliers.

      ReplyDelete
    19. " AOL Mail Not Updating | AOL Mail Not Updating on Iphone
      AOL Mail Not Updating | AOL Mail Not Updating on Iphone. It might be a very common issue for users who is not able to catch their emails."

      ReplyDelete
    20. how to delete aol email? When it comes to deleting your email account without closing the proper account then it is not possible as it means that you are going to lose your things on the services that include Instant Messenger for the emails. All the emails and address books are going to delete permanently after 90 days. So you are not able to recover the account after 90 days.

      How to delete AOL email in bulk for save your time

      So when it comes to deleting your email address then you have to do a lot of things also. Instead of that, you are also able to reactivate a well and get the address book back to do. If you want to know how to delete AOL mail folders to delete all the AOL mail, you need to keep up a consideration towards email. As the different processes need to follow a different types of procedures.

      ReplyDelete
    21. Very nice and informative blog keep posting this type of blogs everyday. this one is helping many online users around the globe & i have one more link to help online users exploring the information on the Internet you can get favourable results. But still, you are not sure why AOL not working then has to implement some general troubleshooting solutions to resolve these types of issues. As sometimes AOL software not working and it will give you a lot of hurdles.

      Aol mail not updating

      ReplyDelete
    22. Make Make AOL my Homepage You can make AOL your default landing page from the AOL site or from your records if you have one. Then again, change the settings in your program. Remember that programs can show home pages in reverse when you are using tabs. For example, Internet Explorer opens your landing page when you open the new tab page. Firefox and Chrome can’t do this as a result, so you may have to physically open your landing page in a new tab by selecting the program’s home or start page icon. Open “make aol my homepage“, search for the “AOL Build My Landing Page” standard, and select it. Follow the directions and confirmation prompts to set up the site as your landing page. In Internet Explorer and Chrome, you add an easy route to AOL that changes your default landing page setting; Similarly, Firefox allows you to change your landing page by dragging the AOL logo onto your landing page symbol.

      Change your home page in browsers

      In Internet Explorer, set up your landing page via Internet Options in the Tools menu; These options highlight a Home segment where you can simply enter “Make AOL my Homepage” In Firefox, change your landing page settings to “Choice” in the open menu instrument, the symbol with the three even lines. Enter “make aol my homepage” in the landing page field; You can also choose whether to have Firefox open AOL on startup here. For Chrome, select “Modify and control Google Chrome” — the symbol with the three-level lines — and use the Settings menu to make changes. You can guide Chrome to show you when AOL opens and set that as your landing page.

      ReplyDelete
    23. Nice Blog…!! Thanks for sharing this article. If you want to be a Mobile Expert. Check out for Mobile Repairing Course In Delhi India .

      ReplyDelete
    24. This comment has been removed by the author.

      ReplyDelete
    25. Pogo com Login Page | Pogo Games Login

      There is no charge for using the site. If you don't want to pay the monthly fee and want to join Club Pogo Login, you can still play games on the site by registering a free account. You can access all the free games on the website, and you can save your progress so that you don't have to restart every time you play the game. You can still chat with other players online and post on the forum to make it more social. You can also take part in daily challenges, but you cannot participate in the advanced challenges offered on the website.

      Paypal Login my Account

      Www Paypal Login

      Pogo Com Login Page

      Www paypal Com Login





      ReplyDelete
    26. If you want change aol password Visit the AOL My Account page. Link Below
      How to change aol password

      ReplyDelete
    27. Simple Guide to Install AOL Desktop Gold Link Below_
      How do I Reinstall AOL Gold

      ReplyDelete
    28. We will first check your requirements carefully, and then provide you with solutions and services. It definitely depends on your more relaxed work scene. Let's take a look at the four options we typically offer consumers for AOL backups: Link Below_
      Forgot AOL Mail Password

      ReplyDelete
    29. You have posted such a nice blog. Please check the link below for more information.

      Make Aol my Homepage
      AOL Email on iPhone not working

      ReplyDelete
    30. I was looking at your post i found that your post are very helpful and informative. I want you to know that you are doing a great job please keep posting this type of blogs and posts regularly apart from that i also have something very interesting and informative that can help everyone i am pasting few links below so you can check that out for more details. Thankyou !

      Aol Not Working on iphone
      Contact Aol

      ReplyDelete
    31. You have posted such a nice blog. Please check the link below for more information.

      Aol Mail Change Password

      ReplyDelete
    32. You have posted a very nice and informative blog. keep posting this type of blog regularly. I also have something very interesting you can check the links below.

      Help Aol Com
      Forgot Aol Password

      ReplyDelete
    33. Hi,
      Thank you for this helpful information.
      This is an excellent and very useful article.
      Thank you for providing this information, and best wishes to all who wish to participate. spoken english online training - NareshIT



      ReplyDelete