Spring Descriptive Questions

Posted by: | Published: Sunday, December 27, 2015 | Categories:

Hello dear student how are you hope that all of you are fine. Here we discuses the topic  Spring Descriptive Questions. In this section we know what is spring?,its advantage, module and many more. so lets start

1) What is Spring?
It is a lightweight, loosely coupled and integrated framework for developing enterprise applications in java.

2) What are the advantages of spring framework?
    • Easy to test
    • Loose Coupling
    • Lightweight
    • Fast Development
    • Predefined Templates
    • Powerful Abstraction
    • Declarative support
      3) What are the modules of spring framework?

        • Test
        • Spring Core Container
        • AOP, Aspects and Instrumentation
        • Data Access/Integration
        • Web
          4) What is IOC and DI?
          IOC (Inversion of Control) and DI (Dependency Injection) is a design pattern to provide loose coupling. It removes the dependency from the program.
          Let's write a code without following IOC and DI.
          1.            public class Employee{  
          2.            address;  
          3.            Employee(){  
          4.            Address  address=new Address();//creating instance  
          5.            }  
          6.            }  
          Now, there is dependency between Employee and Address because Employee is forced to use the same address instance.
          Let's write the IOC or DI code.
          7.            public class Employee{  
          8.            Address address;  
          9.            Employee(Address address){  
          10.         this.address=address;//not creating instance  
          11.         }  
          12.         }  
          Now, there is no dependency between Employee and Address because Employee is not forced to use the same address instance. It can use any address instance.

          5) What is the role of IOC container in spring?
          IOC container is responsible to:
          • create the instance
          • configure the instance, and
          • assemble the dependencies

          6) What are the types of IOC container in spring?
          There are two types of IOC containers in spring framework
          •  BeanFactory
          • ApplicationContext
            7) What is the difference between BeanFactory and ApplicationContext?

            BeanFactory is the basic container whereas ApplicationContext is the advanced container. ApplicationContext extends the BeanFactory interface. ApplicationContext provides more facilities than BeanFactory such as integration with spring AOP, message resource handling for i18n etc.

            8) What is the difference between constructor injection and setter injection?

            Constructor Injection
            Setter Injection
            No Partial Injection
            Partial Injection
            Desn't override the setter property
            Overrides the constructor property if both are defined.
            Creates new instance if any modification occurs
            Doesn't create new instance if you change the property value
            Better for too many properties
            Better for few properties.

            9) What is autowiring in spring? What are the autowiring modes?
            Autowiring enables the programmer to inject the bean automatically. We don't need to write explicit injection logic.
            Let's see the code to inject bean using dependency injection.
                      <bean id="emp" class="com.example.Employee" autowire="byName" />  
            The autowiring modes are given below:
            this is the default mode, it means autowiring is not enabled.
            injects the bean based on the property name. It uses setter method.
            injects the bean based on the property type. It uses setter method.
            It injects the bean using constructor
            The "autodetect" mode is deprecated since spring 3.

            10) What are the different bean scopes in spring?
            There are 5 bean scopes in spring framework.
            The bean instance will be only once and same instance will be returned by the IOC container. It is the default scope.
            The bean instance will be created each time when requested.
            The bean instance will be created per HTTP request.
            The bean instance will be created per HTTP session.
            The bean instance will be created per HTTP global session. It can be used in portlet context only.

            11) In which scenario, you will use singleton and prototype scope?
            Singleton scope should be used with EJB stateless session bean and prototype scope with EJB stateful session bean.

            12) What are the transaction management supports provided by spring?
            Spring framework provides two type of transaction management supports: 
            Programmatic Transaction Management: should be used for few transaction operations. 
            Declarative Transaction Management: should be used for many transaction operations.

              Next Post »

              আপনার কোন কিছু জানার থাকলে কমেন্টস বক্স এ লিখতে পারেন। আমরা যথাযত চেস্টা করব আপনার সঠিক উত্তর দিতে। ভালো লাগলে ধন্যবাদ দিতে ভুলবেন না।
              - শুভকামনায় ওয়েব স্কুল বিডি
              ConversionConversion EmoticonEmoticon