Spring Framework Q&A

[vc_row][vc_column css_animation=”fadeInLeft”][vc_column_text css=”.vc_custom_1562225246319{background-color: #1e73be !important;}”]

Spring Framework Interview Questions & Answers

[/vc_column_text][/vc_column][/vc_row][vc_row css_animation=”fadeInRight”][vc_column css_animation=”fadeInLeft” width=”1/2″][vc_tta_accordion color=”peacoc” active_section=”1″][vc_tta_section title=”What is a spring?” tab_id=”1562225288878-3bb66083-fb2d”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are Advices in Spring?” tab_id=”1562225288895-ce880008-5833″][vc_column_text]It is the execution of an aspect. Advice is like making your application learn a new trick. They are usually introduced at joinpoints.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is the default scope of bean in Spring framework?” tab_id=”1562225313791-7c530efc-a5a8″][vc_column_text]The default scope of bean is Singleton for Spring framework.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Name the types of transaction management that are supported by Spring?” tab_id=”1562225314472-659557e6-e3ef”][vc_column_text]Transaction management supported by Spring are :

  • Declarative transaction management.
  • Programmatic transaction management.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Is Singleton beans are thread safe in Spring Framework?” tab_id=”1562225315040-97c86a4c-c799″][vc_column_text]No, singleton beans are not thread-safe in Spring framework.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the benefits of Spring Framework?” tab_id=”1562225315669-68729d2a-39e3″][vc_column_text]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.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is Bean Factory?” tab_id=”1562225316728-06195d09-4e65″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Define Bean Wiring?” tab_id=”1562225317245-2935a08d-d115″][vc_column_text]Bean wiring is the creation of associations between application components that are between the beans in a particular spring container.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is called Spring MVC?” tab_id=”1562225317776-003edc4f-315b”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Why Spring framework is needed?” tab_id=”1562225318317-6af456bb-1db7″][vc_column_text]Spring framework is needed because it is –

  • Very Light Weight Container
  • Framework
  • IOC
  • AOP

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Name the various modules used in spring framework?” tab_id=”1562225319008-754ea124-9fc6″][vc_column_text]

  • 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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain the RowCallbackHandler in Spring?” tab_id=”1562225319629-0af4666b-b190″][vc_column_text]The RowCallbackHandler is called for each row in ResultSet and is used to read values from the ResultSet.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Define Application context module?” tab_id=”1562225320920-cc5bf2cd-902d”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Write about AOP module?” tab_id=”1562225321461-b5ea2a31-d1ad”][vc_column_text]AOP module is utilized for creating aspects for Spring applications. It also enables support for metadata programming in Spring.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is a BeanFactory Interface?” tab_id=”1562225322072-8ff69be9-99e2″][vc_column_text]Bean factory interface is used to provide configuration framework for object creation and basic functionality around object management.[/vc_column_text][/vc_tta_section][vc_tta_section title=”State the differences between ApplicationContext and BeanFactory in spring?” tab_id=”1562225322624-b17fc148-a800″][vc_column_text]

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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is Auto Wiring?” tab_id=”1562225323125-d5e0f9f8-b9f8″][vc_column_text]Autowiring is used to build relationships between the collaborating beans. Spring container can automatically resolve collaborators for beans.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the different Modes of Autowiring?” tab_id=”1562225323640-c8fcaa17-721e”][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”How to start using spring?” tab_id=”1562225324152-59c2cff3-f3e3″][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the methods of bean life cycle?” tab_id=”1562225325261-2ddc72f8-91e3″][vc_column_text]There are two important methods of Bean life cycle:

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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the different types of events of Listeners?” tab_id=”1562225325813-0666ad3c-e121″][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Differentiate between singleton and prototype bean?” tab_id=”1562225326333-56c8c779-7406″][vc_column_text]Singleton means only one bean is defined per object instance while Prototype means one definition to more than one object instances in Spring.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the types of Dependency Injection?” tab_id=”1562225326849-54492183-e619″][vc_column_text]Two types of dependency injection are supported by spring framework:

  • Setter Injection
  • Constructor Injection

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Write about Core container module?” tab_id=”1562225327449-3731d923-afab”][vc_column_text]Core container module is responsible for the basic functionality of the spring framework. The whole Spring framework is built with this module as a base.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is AOP module?” tab_id=”1562225328507-ece463f7-5b40″][vc_column_text]This AOP module is used for spring enabled application. Support has been provided AOP alliance to ensure the interoperability between spring and other AOP frameworks.

It instructs spring to add annotations to the source code and tell how to apply aspects.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is AOP Alliance?” tab_id=”1562225329331-8b6834dc-2480″][vc_column_text]AOP alliance is an open-source project which is aimed at promoting adoption of AOP. The AOP alliance’s goal is to define a common set of components and interfaces so as to improve interoperability among different AOP implementations.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is called spring configuration file?” tab_id=”1562225329996-bae3f82c-db1e”][vc_column_text]Spring configuration file is an XML file and it contains class information. It also describes how these classes are configured and interact with each other.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are different types of Autowire?” tab_id=”1562225330584-8745d1c2-861f”][vc_column_text]There are four different types of Auto wire:

  • byName
  • byType
  • constructor
  • autodetect

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the types of the transaction management that is supported by spring?” tab_id=”1562225331234-a76551b2-108e”][vc_column_text]Following are the types of transaction management that has been supported by spring:

  • declarative
  • programmatically

[/vc_column_text][/vc_tta_section][vc_tta_section title=”When are declarative and programmatic transaction management used?” tab_id=”1562225332641-f14e50de-e19f”][vc_column_text]When only a small amount of transactional operations is there, it is advised to use Programmatic transaction management. But if there is a big amount of transactional operations to be taken care of, declarative transaction management is preferred.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is IOC?” tab_id=”1562225333202-1f8001fb-72b5″][vc_column_text]IOC (Inversion of Control pattern) is also known as dependency injection. IOC directs the programmers to depict how to create objects instead of actually creating them. But in this design pattern, this control has been given to assembler and assembler will instantiate required class if needed.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Write about the different types of Listener related events?” tab_id=”1562225333858-30a2bfef-6317″][vc_column_text]The different types of events related to listeners are:

  • ContextRefreshedEvent – This gets called when the context is refreshed or initialized.
  • RequestHandledEvent – This gets called when the web context is handling a request.
  • ContextClosedEvent – This gets called when the context gets closed.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is an Aspect?” tab_id=”1562225334350-3266b10b-889a”][vc_column_text]Aspect is also called as logging which is required throughout the application. Logging or aspect is a cross cutting functionality in an application using AOP.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is a Joinpoint?” tab_id=”1562225334937-7ab1194a-9ccb”][vc_column_text]The point where an aspect can be introduced in the application is known as a joinpoint. This point could be a field being modified, a method being called or even an exception being thrown. At these points, the new aspect’s code can be added to introduce a new behavior to the application.

Aspect code can be inserted at this point into normal flow of application to change the current behavior.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is called an Advice?” tab_id=”1562225335577-158a7383-92e6″][vc_column_text]Advice will tell application on new behavior and it is the implementation of an aspect. It is inserted into an application at the joinpoint.

Advice is the implementation of an aspect. It is something like telling your application of a new behavior. Generally, the advice is inserted into an application at joinpoints.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is a Pointcut?” tab_id=”1562225336178-d7b862f8-9f83″][vc_column_text]Pointcut is used to allow where the advice can be applied.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is weaving?” tab_id=”1562225337521-11a1210f-9ef9″][vc_column_text]Weaving is used to create new proxy object by applying aspects to target object.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is difference between singleton and prototype bean?” tab_id=”1562225338258-188d4d18-baf6″][vc_column_text]Singleton Bean – Single bean definition to a single object instance per Spring IOC container

Prototype Bean – Single bean definition to any number of object instances per Spring IOC Container[/vc_column_text][/vc_tta_section][vc_tta_section title=”In what points, can weaving be applied?” tab_id=”1562225338806-41d9dbe1-167a”][vc_column_text]Following are the points where weaving can be applied:

  • Compile Time
  • Class load Time
  • Runtime

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the different types of AutoProxying?” tab_id=”1562225339542-1365e86a-4ba6″][vc_column_text]Following are the different types of AutoProxying:

  • BeanNameAutoProxyCreator
  • DefaultAdvisorAutoProxyCreator
  • Metadata autoproxying

[/vc_column_text][/vc_tta_section][/vc_tta_accordion][/vc_column][vc_column width=”1/2″][vc_tta_accordion color=”peacoc” active_section=”1″][vc_tta_section title=”How can beans be made singleton or prototype?” tab_id=”1562225386130-38416433-cb8b”][vc_column_text]The bean tag has an attribute called ‘singleton’. The bean is singleton if its value is ‘TRUE’, otherwise the bean is a prototype.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What classes are used to Control the database connection?” tab_id=”1562225386154-c7bcafb7-370a”][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Describe about DAO in Spring framework?” tab_id=”1562225460756-3373a698-c43d”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is Autoproxying?” tab_id=”1562225461273-06a9c5e6-b7dd”][vc_column_text]Autoproxying is used to create proxy automatically for the spring users. It provides following two classes to support this automatic proxy creation:

  • BeanNameAutoProxyCreator
  • DefaultAdvisorAutoProxyCreator

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is Metadata Autoproxying?” tab_id=”1562225461813-a2872b36-ab9e”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is ‘Throws advice’ in Spring?” tab_id=”1562225462385-029a8c72-b54c”][vc_column_text]’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)

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the various editors used in spring work?” tab_id=”1562225463490-9f4be8f1-340f”][vc_column_text]The various custom editors provided by the Spring Framework are:

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

[/vc_column_text][/vc_tta_section][vc_tta_section title=” What are the advantages of spring framework?” tab_id=”1562225464109-1c5bb823-95c9″][vc_column_text]Following are the advantages of spring framework:

  • Layered Architecture
  • Enables Plain Old Java Object (POJO) Programming and it enables continuous integration and testability
  • Dependency Injection and Inversion of Control that simplifies JDBC
  • Open source framework which can be used for commercial purpose

[/vc_column_text][/vc_tta_section][vc_tta_section title=” How is Hibernate accessed using the Spring framework?” tab_id=”1562225464789-38b5eeb2-86cc”][vc_column_text]Hibernate can be accessed in the following two ways:

  • By IOC with a Callback and HibernateTemplate.
  • By applying an AOP Interceptor and broadening the HibernateDaoSupport.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the various Channels supported by Spring 2.0?” tab_id=”1562225465322-cc35581a-7426″][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=” Why is declarative transaction management preferred in Spring?” tab_id=”1562225465941-541b71b3-6b3e”][vc_column_text]Declarative transaction management has minimum impact on the application code and, therefore, is an idealistic lightweight container.[/vc_column_text][/vc_tta_section][vc_tta_section title=” Explain the concept of a BeanFactory?” tab_id=”1562225466497-aae2eed5-67db”][vc_column_text]BeanFactory applies the idea of a factory pattern that utilizes IOC to separate the application’s dependencies and configuration from the actual code.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the different scopes of spring bean?” tab_id=”1562225467017-dbed93f7-0dab”][vc_column_text]Scopes of spring bean are Singleton, prototype, request, session and global session.[/vc_column_text][/vc_tta_section][vc_tta_section title=” What are all the ways to access Hibernate by using Spring?” tab_id=”1562225468417-f7c923c2-7a09″][vc_column_text]There are two ways to access hibernate using spring:

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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”How struts application can be integrated with spring?” tab_id=”1562225469058-7a061143-fef0″][vc_column_text]There are two options for struts application that can be integrated with spring:

Configuration of Spring to manage beans using ContextLoader plugin and set their dependencies in a spring context file

Grab spring managed beans explicitly using agetwebapplicationcontext()[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is Inversion of control (IOC)?” tab_id=”1562225469633-380f939c-2342″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Write the benefits of using IOC?” tab_id=”1562225470134-e69af22b-a4d5″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is Inner bean? What is the drawback of inner bean?” tab_id=”1562225470721-0bdb13e7-8208″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the different types of Injection in spring?” tab_id=”1562225471257-fdf09063-ff0a”][vc_column_text]There are three types of Injection in spring:

  • Setter Injection
  • Constructor Injection
  • Getter or Method Injection

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the benefits of spring framework?” tab_id=”1562225471788-f63e0cce-92a9″][vc_column_text]Following are the benefits of spring framework:

  • Light weight container when compared to j2EE containers
  • Built in Web MVC framework
  • Creates loosely coupled applications
  • Supports aspect oriented programming like logging, transaction and security
  • Configuration done in XML format which is easy to write and understand

[/vc_column_text][/vc_tta_section][vc_tta_section title=” What are the types of Advice?” tab_id=”1562225472410-a843eca3-f4ab”][vc_column_text]There are five types of Advice:

  • Before Advice
  • After returning advice
  • After throwing advice
  • Finally advice
  • Around advice

[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is called PreparedStatementCreator?” tab_id=”1562225473714-d8ff443c-6b93″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is SQLProvider?” tab_id=”1562225474426-94386fdb-d3b9″][vc_column_text]SQLProvider has only one method called getSql()and it is implemented using PreparedStatementCreator implementers. It is mainly used for debugging.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Write about BatchPreparedStatementSetter?” tab_id=”1562225474957-56f7d1f6-a5f0″][vc_column_text]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

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is the better method of using JDBC in Spring?” tab_id=”1562225475566-1f517584-08cf”][vc_column_text]If JDBC is used with the template class called JdbcTemplate, it gives a better performance.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What exceptions do the DAO classes, use in Spring throw?” tab_id=”1562225476262-665a9843-c280″][vc_column_text]In spring DAO classes only throws SQLException.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Explain the advantages of using DAO module?” tab_id=”1562225476874-9c8a25b9-6b93″][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Name the significant ApplicationContext implementations used in the spring framework?” tab_id=”1562225477482-66e11fa0-eb33″][vc_column_text]They are:

  • ClassPathXmlApplicationContext
  • FileSystemXmlApplicationContext
  • XmlWebApplicationContext

[/vc_column_text][/vc_tta_section][vc_tta_section title=”How is a bean added to a Spring application?” tab_id=”1562225478811-4f2c9bb5-7c4d”][vc_column_text]

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN">

<beans>

<bean id="foo"/>

<bean id="bar"/>

</beans>

The bean tag has an ID attribute which stores the bean name and a class attributes which specifies the full class name.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are ORM integration modules?” tab_id=”1562225479418-b7c12c6d-179a”][vc_column_text]Object/relational mapping (ORM) tool is supported by Spring over straight JDBC by implementing the ORM module. Spring can join various important ORM frameworks, including JDO, iBATIS SQL Maps and Hibernate.[/vc_column_text][/vc_tta_section][vc_tta_section title=”Mention and explain the types of Advice in Spring?” tab_id=”1562225480018-c2b4777d-4687″][vc_column_text]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.

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is the web module?” tab_id=”1562225480642-1fded930-8f45″][vc_column_text]The web module enables the creation of a web application without XML. The web.xml file needs to be configured for using the web module.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is DataAccessException?” tab_id=”1562225481314-fa169512-ed96″][vc_column_text]DataAccessException is a RuntimeException. It is an Unchecked Exception. The user cannot be forced to handle these kinds of exceptions.[/vc_column_text][/vc_tta_section][vc_tta_section title=” What is XMLBeanFactory?” tab_id=”1562225481963-eff2e769-af86″][vc_column_text]Spring includes several applications of Bean factory. Out of these, org.springframework.beans.factory.xml.XmlBeanFactory is a very important one. It loads the beans on the basis of the definitions stored in an XML file. For the creation of an XmlBeanFactory, a java.io.InputStream is passed to the constructor. The InputStream provides the XML to the factory. For example, for retrieval of the bean, the getBean() method is called by passing the name of the desired bean.

MyBean helloBean = (MyBean) factory.getBean("helloBean");

[/vc_column_text][/vc_tta_section][vc_tta_section title=”Name the Exception class which is connected to the exceptions thrown by the applications?” tab_id=”1562225483447-df7a1c96-76d3″][vc_column_text]It is the DataAccessException given by org.springframework.dao.DataAccessException[/vc_column_text][/vc_tta_section][vc_tta_section title=”Mention the types of lOC (dependency injection)?” tab_id=”1562225484236-03799f60-e32d”][vc_column_text]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.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What are the important beans lifecycle methods?” tab_id=”1562225484958-48866e80-a0a4″][vc_column_text]All in all, two bean lifecycle methods are there. The first method is the setup method which is called during the loading of the bean into the container. The second is when the bean is unloaded from the container, and this method is called the teardown.[/vc_column_text][/vc_tta_section][vc_tta_section title=” How can the default lifecycle methods of beans be nullified?” tab_id=”1562225485639-dc3a6229-cb78″][vc_column_text]The tag, bean, has two useful attributes which can be used to define special initialization and destruction methods.

For Example, two new methods forSetup and forTeardown can be added to the Foo class in the following way:

<beans>

<bean id="bar" init-method="forSetup" destroy="forTeardown"/>

</beans>

[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is a Target?” tab_id=”1562225486351-37b5d22a-91f1″][vc_column_text]A target is the class that is advised. This class can either be a class to which we want to add a special behavior to or a third party class. The target class is free to center on its major concern using the AOP concepts, regardless of any advice that is being applied.[/vc_column_text][/vc_tta_section][vc_tta_section title=”What is cross cutting concern and concern in spring AOP?” tab_id=”1562225487187-0a015392-7d9c”][vc_column_text]Cross cutting concern: It is a concern which is applicable throughout the application and it affects the entire application. E.g Security, logging and data transfer are the concerns which are needed in almost every module of an application.[/vc_column_text][/vc_tta_section][/vc_tta_accordion][/vc_column][/vc_row]

WhatsApp us