• +91 9723535972
  • info@interviewmaterial.com

Spring Interview Questions and Answers

Spring Interview Questions and Answers

Question - 1 : - What are the different IOC containers available?

Answer - 1 : - Spring is an IOC container. Other IOC containers are HiveMind, Avalon, PicoContainer.

Question - 2 : - What are the advantages of spring framework?

Answer - 2 : - Spring has layed architecture. Use what you need and leave you don't need now. Spring Enables POJO Programming. There is no behind the scene magic here. POJO programming enables continous integration and testability. Dependency Injection and Inversion of Control Simplifies JDBC (Read the first question.) Open source and no vendor lock-in.

Question - 3 : - Can you name a tool which could provide the initial ant files and directory structure for a new spring project.

Answer - 3 : - Appfuse or equinox.

Question - 4 : - How does Spring supports DAO in hibernate?

Answer - 4 : - Spring’s HibernateDaoSupport class is a convenient super class for Hibernate DAOs. It has handy methods you can call to get a Hibernate Session, or a SessionFactory. The most convenient method is getHibernateTemplate(), which returns a HibernateTemplate. This template wraps Hibernate checked exceptions with runtime exceptions, allowing your DAO interfaces to be Hibernate exception-free. Example:  public class UserDAOHibernate extends HibernateDaoSupport {   public User getUser(Long id) { return (User) getHibernateTemplate().get(User.class, id); } public void saveUser(User user) { getHibernateTemplate().saveOrUpdate(user); if (log.isDebugEnabled()) { log.debug(“userId set to: “ + user.getID()); } } public void removeUser(Long id) { Object user = getHibernateTemplate().load(User.class, id); getHibernateTemplate().delete(user); }   }

Question - 5 : - How is a typical spring implementation look like?

Answer - 5 : - For a typical Spring Application we need the following files    1. An interface that defines the functions. 2. An Implementation that contains properties, its setter and getter methods, functions etc., 3. A XML file called Spring configuration file. 4. Client program that uses the function.

Question - 6 : -  How do you define hibernate mapping file in spring?

Answer - 6 : - Add the hibernate mapping file entry in mapping resource inside Spring’s applicationContext.xml file in the web/WEB-INF directory.                org/appfuse/model/User.hbm.xml      

Question - 7 : - How do you configure spring in a web application?

Answer - 7 : - It is very easy to configure any J2EE-based web application to use Spring. At the very least, you can simply add Spring’s ContextLoaderListener to your web.xml file:       org.springframework.web.context.ContextLoaderListener

Question - 8 : - What are the key benifits of Hibernate?

Answer - 8 : - These are the key benifits of Hibernate: Transparent persistence based on POJOs without byte code processing  Powerful object-oriented hibernate query language Descriptive O/R Mapping through mapping file. Automatic primary key generation  Hibernate cache : Session Level, Query and Second level cache. Performance: Lazy initialization, Outer join fetching, Batch fetching

Question - 9 : - What Is Spring Framework?

Answer - 9 : -

Spring is the most broadly used framework for the development of Java Enterprise Edition applications. Further, the core features of Spring can be used in developing any Java application.

We use its extensions for building various web applications on top of the Jakarta EE platform. We can also just use its dependency injection provisions in simple standalone applications.

Question - 10 : - What Are the Benefits of Using Spring?

Answer - 10 : -

Spring targets to make Jakarta EE development easier, so let's look at the advantages:

  • Lightweight – There is a slight overhead of using the framework in development.
  • Inversion of Control (IoC) – Spring container takes care of wiring dependencies of various objects instead of creating or looking for dependent objects.
  • Aspect-Oriented Programming (AOP) – Spring supports AOP to separate business logic from system services.
  • IoC container – manages Spring Bean life cycle and project-specific configurations
  • MVC framework – used to create web applications or RESTful web services, capable of returning XML/JSON responses
  • Transaction management – reduces the amount of boilerplate code in JDBC operations, file uploading, etc., either by using Java annotations or by Spring Bean XML configuration file
  • Exception Handling – Spring provides a convenient API for translating technology-specific exceptions into unchecked exceptions.

NCERT Solutions


Share your email for latest updates


Our partners