Spring mvc interview questions

What is a spring?

Spring is set to be a framework which helps Java programmer for development of code and it provides IOC container, Dependency Injector, MVC flow and many other APIs for the java programmer.

What are Advices in Spring?

It is the execution of an aspect. Advice is like making your application learn a new trick. They are usually introduced at joinpoints.

What is the default scope of bean in Spring framework?

The default scope of bean is Singleton for Spring framework.

Name the types of transaction management that are supported by Spring?

Transaction management supported by Spring are :

  •  Declarative transaction management.
  •  Programmatic transaction management.

Is Singleton beans are thread safe in Spring Framework?

No, singleton beans are not thread-safe in Spring framework.

What are the benefits of Spring Framework?

Following are the benefits of Spring framework:

  • Extensive usage of Components
  • Reusability
  • Decoupling
  • Reduces coding effort by using pattern implementations such as singleton, factory, service locator etc.
  • Removal of leaking connections
  • Declarative transaction management
  • Easy to integrate with third party tools and technologies.

What is Bean Factory?

Bean Factory is core of the spring framework and, it is a Lightweight container which loads bean definitions and manages your beans.  Beans are configured using XML file and manage singleton defined bean. It is also responsible for life cycle methods and injects dependencies. It also removes adhoc singletons and factories.

Define Bean Wiring?

Bean wiring is the creation of associations between application components that are between the beans in a particular spring container.

What is called Spring MVC?

A Spring MVC is a single shared controller instance and it is used to handle request type controllers, interceptors which run in the IoC container. It also allows multiple Dispatcher Servlets which can share application context interface but not class based interface.

Why Spring framework is needed?

Spring framework is needed because it is –

  • Very Light Weight Container
  • Framework
  • IOC
  • AOP

Name the various modules used in spring framework?

  • AOP module (Aspect Oriented Programming)
  • JDBC abstraction and DAO module
  • The Core container module
  • MVC framework module
  • Application context module
  • O/R mapping integration module (Object/Relational)
  • Web module

Explain the RowCallbackHandler in Spring?

The RowCallbackHandler is called for each row in ResultSet and is used to read values from the ResultSet.

Define Application context module?

This is a very important module and supplies various necessary services like EJB integration, remoting, JNDI access and scheduling. It transforms spring into a framework. It also broadens the idea of BeanFactory by application of lifecycle events, providing support for internationalization messages and validation.

Write about AOP module?

AOP module is utilized for creating aspects for Spring applications. It also enables support for metadata programming in Spring.

What is a BeanFactory Interface?

Bean factory interface is used to provide configuration framework for object creation and basic functionality around object management.

State the differences between ApplicationContext and BeanFactory in spring?

  • ApplicationContext allows more than one config files to exist while BeanFactory only permits one.
  • ApplicationContext can print events to beans registered as listeners. This feature is not supported by BeanFactory.
  • ApplicationContext also provides support for application of lifecycle events, internationalization messages and validation and also provides services like EJB integration, remoting, JNDI access and scheduling. These features too are not supported by Bean Factory.

What is Auto Wiring?

Autowiring is used to build relationships between the collaborating beans. Spring container can automatically resolve collaborators for beans.

What are the different Modes of Autowiring?

Autowiring has five different modes:

  • no: no autowire
  • byName : Autowiring that can be done by property name
  • byType : property type as autowired
  • constructor: It is similar to byType and it is property is in constructor
  • autodetect :  Spring is allowed to select autowiring from byType or constructor

How to start using spring?

Following steps needs to be done to start with the Spring:

  • Download Spring and its dependent file from spring’s site.
  • Create application context xml to define beans and its dependencies
  • Integrate application context xml with web.xml
  • Deploy and Run the application

What are the methods of bean life cycle?

There are two important methods of Bean life cycle:

  • Setup – called when bean is loaded into container
  • Teardown – called when bean is unloaded into container

What are the different types of events of Listeners?

Following are the different types of events of listeners:

  • ContextClosedEvent – This event is called when the context is closed.
  • ContextRefreshedEvent – This event is called when context is initialized or refreshed
  • RequestHandledEvent – This event is called when the web context handles request

Differentiate between singleton and prototype bean?

Singleton means only one bean is defined per object instance while Prototype means one definition to more than one object instances in Spring.

Summary
Review Date
Reviewed Item
Very useful..! Spring MVC Interview Questions and Answers...! please keep updating...!
Author Rating
51star1star1star1star1star