Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Mention The Types Of Loc (dependency Injection)?

Answer»

The different TYPES of loC are: –

  • Setter Injection: With the help of JavaBeans properties.
  • Constructor Injection: Dependencies are given in the FORM of constructor parameters.
  • INTERFACE Injection: With the help of an interface, an Injection is performed.

Out of these three, only construction and setter are being USED in SPRING.

The different types of loC are: –

Out of these three, only construction and setter are being used in Spring.

2.

Name The Exception Class Which Is Connected To The Exceptions Thrown By The Applications?

Answer»

It is the DATAACCESSEXCEPTION GIVEN by org.springframework.dao.DataAccessException

It is the DataAccessException given by org.springframework.dao.DataAccessException

3.

Mention And Explain The Types Of Advice In Spring?

Answer»

Types of advice are:

  • Before advice: Advice that is EXECUTED prior to a joinpoint is called the ‘before advice’.
  • After returning advice: Advice that is executed after the NORMAL completion of a joinpoint is called the ‘after returning advice’.
  • After throwing advice: Advice that is executed only if a method exits ABNORMALLY by throwing an EXCEPTION, is called the ‘after throwing advice’.
  • After (finally) advice: Advice that is executed irrespective of how a joinpoint exits is called ‘after finally advice’.
  • Around advice: Advice that borders a joinpoint, for example, a method invocation, is called an ‘around advice’. This can be used to perform special ACTIVITIES before and after the invocation of method.

Types of advice are:

4.

Name The Significant Applicationcontext Implementations Used In The Spring Framework?

Answer»

They are:

  • ClassPathXmlApplicationContext
  • FileSystemXmlApplicationContext
  • XmlWebApplicationContext

They are:

5.

Explain The Advantages Of Using Dao Module?

Answer»

The database code can be kept clean and simple by USING the DAO module. This helps in PREVENTING problems that rise because of poor handling of closures of database resources. Also, the DAO module utilizes the AOP module to enable objects in the Spring application to use transaction MANAGEMENT SERVICES.

The database code can be kept clean and simple by using the DAO module. This helps in preventing problems that rise because of poor handling of closures of database resources. Also, the DAO module utilizes the AOP module to enable objects in the Spring application to use transaction management services.

6.

Write About Batchpreparedstatementsetter?

Answer»

BatchPreparedStatementSetter is USED to update more than a single row in one go, they can use BatchPreparedStatementSetter. This interface PROVIDES two methods they are

  • setValues( PreparedStatement ps, INT i) throws SOL EXCEPTION
  • int getBatchSize

BatchPreparedStatementSetter is used to update more than a single row in one go, they can use BatchPreparedStatementSetter. This interface provides two methods they are

7.

What Is Sqlprovider?

Answer»

SQLProvider has only one method CALLED getSql()and it is IMPLEMENTED USING PREPAREDSTATEMENTCREATOR IMPLEMENTERS. It is mainly used for debugging.

SQLProvider has only one method called getSql()and it is implemented using PreparedStatementCreator implementers. It is mainly used for debugging.

8.

What Is Called Preparedstatementcreator?

Answer»

PreparedStatementCreator is one of the most commonly used INTERFACES for writing data to the database. createPreparedStatement() is a method that can be used to create and return PREPAREDSTATEMENT from the CONNECTION argument, and exception HANDLING is automatically taken care of. When this interface is implemented, a different interface SqlProvider can also be implemented which has a method CALLED getSql(). This method is useful for providing sql strings to the JdbcTemplate. It does not handle SQLExceptions.

PreparedStatementCreator is one of the most commonly used interfaces for writing data to the database. createPreparedStatement() is a method that can be used to create and return PreparedStatement from the Connection argument, and exception handling is automatically taken care of. When this interface is implemented, a different interface SqlProvider can also be implemented which has a method called getSql(). This method is useful for providing sql strings to the JdbcTemplate. It does not handle SQLExceptions.

9.

What Are The Different Types Of Injection In Spring?

Answer»

There are three TYPES of Injection in spring:

There are three types of Injection in spring:

10.

What Is Inner Bean? What Is The Drawback Of Inner Bean?

Answer»

If a bean ELEMENT is DIRECTLY embedded in a property tag while wiring beans, then the bean is CALLED Inner Bean. Its DRAWBACK is that it cannot be reprocessed.

If a bean element is directly embedded in a property tag while wiring beans, then the bean is called Inner Bean. Its drawback is that it cannot be reprocessed.

11.

Write The Benefits Of Using Ioc?

Answer»

The major benefits of dependency injection or IOC are that it reduces the AMOUNT of coding required for the application. This ALLOWS the TESTING of the application to be done quickly and easily as no JNDI lookup mechanism or singletons are required. IOC containers also support lazy loading and eager INSTALLATION of services.

The major benefits of dependency injection or IOC are that it reduces the amount of coding required for the application. This allows the testing of the application to be done quickly and easily as no JNDI lookup mechanism or singletons are required. IOC containers also support lazy loading and eager installation of services.

12.

What Is Inversion Of Control (ioc)?

Answer»

Inversion of Control (IOC) is ALSO called as dependency Injection which is nothingbut a design pattern that GIVES control to the ASSEMBLER of classes. In general, class will instantiate ANOTHER class if REQUIRED.

But in this design pattern, this control has been to given to assembler and assembler will instantiate required class if needed.

Inversion of Control (IOC) is also called as dependency Injection which is nothingbut a design pattern that gives control to the assembler of classes. In general, class will instantiate another class if required.

But in this design pattern, this control has been to given to assembler and assembler will instantiate required class if needed.

13.

What Are All The Ways To Access Hibernate By Using Spring?

Answer»

There are two ways to ACCESS hibernate USING spring:

There are two ways to access hibernate using spring:

14.

What Are The Different Scopes Of Spring Bean?

Answer»

Scopes of spring BEAN are Singleton, prototype, REQUEST, SESSION and GLOBAL session.

Scopes of spring bean are Singleton, prototype, request, session and global session.

15.

Explain The Concept Of A Beanfactory?

Answer»

BeanFactory applies the IDEA of a FACTORY pattern that utilizes IOC to separate the application’s dependencies and configuration from the ACTUAL code.

BeanFactory applies the idea of a factory pattern that utilizes IOC to separate the application’s dependencies and configuration from the actual code.

16.

Why Is Declarative Transaction Management Preferred In Spring?

Answer»

DECLARATIVE TRANSACTION management has MINIMUM IMPACT on the application code and, therefore, is an idealistic lightweight container.

Declarative transaction management has minimum impact on the application code and, therefore, is an idealistic lightweight container.

17.

What Are The Various Channels Supported By Spring 2.0?

Answer»

Following are the channels supported by spring VERSION 2.0:

  • Pollable Channel
  • Subscribable Channel
  • PublishSubscribe Channel
  • Queue Channel
  • PRIORITY Channel
  • Rendezvous Channel
  • Direct Channel
  • EXECUTOR Channel
  • SCOPED Channel

Following are the channels supported by spring version 2.0:

18.

How Is Hibernate Accessed Using The Spring Framework?

Answer»

Hibernate can be accessed in the FOLLOWING two ways:

Hibernate can be accessed in the following two ways:

19.

What Are The Various Editors Used In Spring Work?

Answer»

The VARIOUS custom EDITORS PROVIDED by the SPRING Framework are:

  • PropertyEditor
  • URLEditor
  • ClassEditor
  • CustomDateEditor
  • FileEditor
  • LocaleEditor
  • StringArrayPropertyEditor
  • StringTrimmerEditor

The various custom editors provided by the Spring Framework are:

20.

What Is ‘throws Advice’ In Spring?

Answer»

‘Throws ADVICE’ define the behavior when an EXCEPTION occurs. It is an interface and it has no methods which need to be implemented.

A class that implements this interface should have METHOD with this signature:

  • Void samplethrow (Throw table t)
  • Void samplethrow(Method m, Object[] o, Object TARGET, Throw tablet)

‘Throws Advice’ define the behavior when an exception occurs. It is an interface and it has no methods which need to be implemented.

A class that implements this interface should have method with this signature:

21.

What Is Metadata Autoproxying?

Answer»

Metadata Autoproxying can be performed INSPIRING which can be driven by metadata. This is determined by source level ATTRIBUTES and KEEPS metadata inside the source code.

This maintains metadata in one PLACE and mainly used for declarative transaction support.

Metadata Autoproxying can be performed inspiring which can be driven by metadata. This is determined by source level attributes and keeps metadata inside the source code.

This maintains metadata in one place and mainly used for declarative transaction support.

22.

What Is Autoproxying?

Answer»

AUTOPROXYING is used to create proxy automatically for the spring users.

It provides FOLLOWING TWO classes to support this automatic proxy creation:

  • BeanNameAutoProxyCreator
  • DefaultAdvisorAutoProxyCreator

Autoproxying is used to create proxy automatically for the spring users.

It provides following two classes to support this automatic proxy creation:

23.

Describe About Dao In Spring Framework?

Answer»

DAO is used to provide integration of JAVA DATABASE connectivity and Object relational mapping objects. DAO is spring framework PROVIDES connection for JDBC, hibernate, JDO, JPA, Common CLIENT interface and Oracle.

DAO is used to provide integration of Java database connectivity and Object relational mapping objects. DAO is spring framework provides connection for JDBC, hibernate, JDO, JPA, Common client interface and Oracle.

24.

What Classes Are Used To Control The Database Connection?

Answer»

Following are the classes that are used to control database CONNECTION:

  • Data SOURCE Utils
  • SmartData Source
  • AbstractData Source
  • SingleConnection DATASOURCE
  • DriverManager DataSource
  • TransactionAware DataSourceProxy
  • DataSource TransactionManager

Following are the classes that are used to control database connection:

25.

How Can Beans Be Made Singleton Or Prototype?

Answer»

The BEAN tag has an attribute called ‘SINGLETON’. The bean is singleton if its value is ‘TRUE’, otherwise the bean is a PROTOTYPE.

The bean tag has an attribute called ‘singleton’. The bean is singleton if its value is ‘TRUE’, otherwise the bean is a prototype.

26.

What Are The Different Types Of Autoproxying?

Answer»

FOLLOWING are the DIFFERENT TYPES of AUTOPROXYING:

  • BeanNameAutoProxyCreator
  • DefaultAdvisorAutoProxyCreator
  • METADATA autoproxying

Following are the different types of AutoProxying:

27.

In What Points, Can Weaving Be Applied?

Answer»

Following are the POINTS where weaving can be APPLIED:

  • Compile Time
  • Class load Time
  • RUNTIME

Following are the points where weaving can be applied:

28.

State The Differences Between Applicationcontext And Beanfactory In Spring?

Answer»
  • 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.

29.

What Is A Spring?

Answer»

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.

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.