• +91 9723535972
  • info@interviewmaterial.com

Spring Interview Questions and Answers

Spring Interview Questions and Answers

Question - 61 : - In Spring, what is Weaving?

Answer - 61 : -

The process of linking an aspect with other application types or objects to create an advised object is called Weaving. In Spring AOP, weaving is performed at runtime. Refer the below diagram:

Question - 62 : - What are the difference between Spring AOP and AspectJ AOP?

Answer - 62 : -

Spring AOP vs AspectJ AOP

Spring AOP

AspectJ AOP

Runtime weaving through proxy is done

Compile time weaving through AspectJ Java tools is done 

It supports only method level PointCut

It suports field level Pointcuts

It is DTD based 

It is schema based and Annotation configuration

Question - 63 : - What are the different types of Advices?

Answer - 63 : -

Different types of Advices in Spring AOP are:

  • Before: These types of advices execute before the joinpoint methods and are configured using @Before annotation mark.
  • After returning: These types of advices execute after the joinpoint methods completes executing normally and are configured using @AfterReturning annotation mark.
  • After throwing:  These types of advices execute only if joinpoint method exits by throwing an exception and are configured using @AfterThrowing annotation mark.
  • After (finally): These types of advices execute after a joinpoint method, regardless of the method’s exit whether normally or exceptional return and are configured using @After annotation mark.
  • Around: These types of advices execute before and after a joinpoint and are configured using @Around annotation mark.

Question - 64 : - Explain JoinPoint.

Answer - 64 : - A point during the execution of a program is called JoinPoint, such as the execution of a method or the handling of an exception. In Spring AOP, a joinpoint always represents a method execution.

Question - 65 : - What do you mean by Aspect?

Answer - 65 : -

Aspect is a modularization of concern which cuts across multiple objects. Transaction management is a good example of a crosscutting concern in J2EE applications. Aspects are implemented using regular classes or regular classes annotated with the @Aspect annotation in Spring Framework.

Question - 66 : - Name the types of transaction management that Spring supports.

Answer - 66 : -

Two types of transaction management are supported by Spring. They are:

  1. Programmatic transaction management: In this, the transaction is managed with the help of programming. It provides you extreme flexibility, but it is very difficult to maintain.
  2. Declarative transaction management: In this, the transaction management is separated from the business code. Only annotations or XML based configurations are used to manage the transactions.

Question - 67 : - What are the ways by which Hibernate can be accessed using Spring?

Answer - 67 : -

There are two ways by which we can access Hibernate using Spring:

  • Inversion of Control with a Hibernate Template and Callback
  • Extending HibernateDAOSupport and Applying an AOP Interceptor node

Question - 68 : - Which classes are present in spring JDBC API?

Answer - 68 : -

Classes present in JDBC API are as follows:

  • JdbcTemplate
  • SimpleJdbcTemplate
  • NamedParameterJdbcTemplate
  • SimpleJdbcInsert
  • SimpleJdbcCall

Question - 69 : - Describe Spring DAO support?

Answer - 69 : -

The Data Access Object (DAO) support in Spring makes it easy to work with data access technologies like JDBC, Hibernate or JDO in a consistent way. This allows one to switch between the persistence technologies easily. It also allows you to code without worrying about catching exceptions that are specific to each of these technology.

Question - 70 : - What are the bean scopes available in Spring?

Answer - 70 : -

The Spring Framework has five scope supports. They are:

  • Singleton: The scope of bean definition while using this would be a single instance per IoC container.
  • Prototype: Here, the scope for a single bean definition can be any number of object instances.
  • Request: The scope of the bean definition is an HTTP request.
  • Session: Here, the scope of the bean definition is HTTP-session.
  • Global-session: The scope of the bean definition here is a Global HTTP session.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners