Top 50 Spring Mvc Framework Interview Questions
Q1. What Are The Various Editors Used In Spring Work?
The diverse custom editors provided by way of the Spring Framework are:
PropertyEditor
URLEditor
ClassEditor
CustomDateEditor
FileEditor
LocaleEditor
StringArrayPropertyEditor
StringTrimmerEditor
Q2. What Are The Different Modes Of Autowiring?
Autowiring has 5 specific modes:
no: no autowire
byName : Autowiring that can be accomplished by using assets name
byType : belongings type as autowired
constructor: It is just like byType and it is belongings is in constructor
autodetect : Spring is authorized to select autowiring from byType or constructor
Q3. Mention The Types Of Loc (dependency Injection)?
The one-of-a-kind kinds of loC are: –
Setter Injection: With the help of JavaBeans properties.
Constructor Injection: Dependencies are given inside the shape of constructor parameters.
Interface Injection: With the assist of an interface, an Injection is carried out.
Out of those three, best production and setter are being used in Spring.
Q4. Name The Significant Applicationcontext Implementations Used In The Spring Framework?
They are:
ClassPathXmlApplicationContext
FileSystemXmlApplicationContext
XmlWebApplicationContext
Q5. What Is Dataaccessexception?
DataAccessException is a RuntimeException. It is an Unchecked Exception. The user cannot be forced to handle those types of exceptions.
Q6. What Are The Types Of Dependency Injection?
Two forms of dependency injection are supported through spring framework:
Setter Injection
Constructor Injection
Q7. What Are All The Ways To Access Hibernate By Using Spring?
There are approaches to get admission to hibernate the usage of spring:
Inversion of Control with a Hibernate Template and Callback
Extending HibernateDAOSupport and Applying an AOP Interceptor node.
Q8. Explain The Advantages Of Using Dao Module?
The database code may be kept easy and easy by way of the use of the DAO module. This helps in preventing issues that upward push because of negative handling of closures of database assets. Also, the DAO module utilizes the AOP module to enable items in the Spring utility to apply transaction management services.
Q9. When Are Declarative And Programmatic Transaction Management Used?
When best a small amount of transactional operations is there, it's miles cautioned to apply Programmatic transaction control. But if there's a huge amount of transactional operations to be taken care of, declarative transaction control is desired.
Q10. What Are The Different Types Of Injection In Spring?
There are 3 varieties of Injection in spring:
Setter Injection
Constructor Injection
Getter or Method Injection
Q11. What Is A Beanfactory Interface?
Bean factory interface is used to provide configuration framework for object advent and primary capability round item control.
Q12. What Is A Spring?
Spring is set to be a framework which facilitates Java programmer for improvement of code and it gives IOC box, Dependency Injector, MVC go with the flow and lots of different APIs for the java programmer.
Q13. What Is Difference Between Singleton And Prototype Bean?
Singleton Bean: – Single bean definition to a unmarried item instance according to Spring IOC container
Prototype Bean: – Single bean definition to any range of object instances in line with Spring IOC Container
Q14. Write About Aop Module?
AOP module is applied for creating factors for Spring programs. It additionally enables assist for metadata programming in Spring.
Q15. What Are The Advantages Of Spring Framework?
Following are the advantages of spring framework:
Layered Architecture
Enables Plain Old Java Object (POJO) Programming and it allows non-stop integration and testability
Dependency Injection and Inversion of Control that simplifies JDBC
Open supply framework which may be used for industrial purpose
Q16. What Is Weaving?
Weaving is used to create new proxy item with the aid of applying aspects to goal object.
Q17. What Is A Target?
A goal is the elegance this is advised. This elegance can either be a category to which we need to feature a unique behavior to or a 3rd celebration magnificence. The target elegance is unfastened to middle on its important concern the use of the AOP concepts, regardless of any recommendation this is being carried out.
Q18. Name The Types Of Transaction Management That Are Supported By Spring?
Transaction control supported through Spring are :
Declarative transaction management.
Programmatic transaction management.
Q19. What Is Called Spring Mvc?
A Spring MVC is a unmarried shared controller instance and it's miles used to deal with request kind controllers, interceptors which run inside the IoC box. It also lets in multiple Dispatcher Servlets which can share application context interface however no longer class primarily based interface.
Q20. Describe About Dao In Spring Framework?
DAO is used to offer integration of Java database connectivity and Object relational mapping objects. DAO is spring framework affords connection for JDBC, hibernate, JDO, JPA, Common patron interface and Oracle.
Q21. What Is A Joinpoint?
The point in which an factor may be introduced in the software is referred to as a joinpoint. This factor could be a field being modified, a technique being known as or even an exception being thrown. At these points, the brand new factor’s code can be brought to introduce a brand new conduct to the software.
Aspect code may be inserted at this point into ordinary waft of software to trade the modern-day conduct.
Q22. How To Start Using Spring?
Following steps needs to be executed to start with the Spring:
Download Spring and its structured document from spring’s site.
Create utility context xml to outline beans and its dependencies
Integrate utility context xml with web.Xml
Deploy and Run the application
Q23. Why Is Declarative Transaction Management Preferred In Spring?
Declarative transaction management has minimal impact at the software code and, therefore, is an idealistic light-weight field.
Q24. Differentiate Between Singleton And Prototype Bean?
Singleton manner simplest one bean is defined in step with item example even as Prototype method one definition to multiple object instances in Spring.
Q25. What Are The Methods Of Bean Life Cycle?
There are two vital methods of Bean existence cycle:
Setup – referred to as whilst bean is loaded into field
Teardown – called while bean is unloaded into field
Q26. Mention And Explain The Types Of Advice In Spring?
Types of recommendation are:
Before advice: Advice that is finished previous to a joinpoint is called the ‘earlier than recommendation’.
After returning advice: Advice that is achieved after the everyday finishing touch of a joinpoint is called the ‘after returning advice’.
After throwing advice: Advice this is completed handiest if a way exits abnormally by way of throwing an exception, is referred to as the ‘after throwing recommendation’.
After (finally) recommendation: Advice that is completed no matter how a joinpoint exits is referred to as ‘after sooner or later recommendation’.
Around advice: Advice that borders a joinpoint, as an instance, a method invocation, is referred to as an ‘around advice’. This can be used to perform unique activities earlier than and after the invocation of method.
Q27. What Is Called An Advice?
Advice will tell application on new conduct and it is the implementation of an issue. It is inserted into an utility at the joinpoint.
Advice is the implementation of an aspect. It is something like telling your utility of a new conduct. Generally, the recommendation is inserted into an software at joinpoints.
Q28. How Is Hibernate Accessed Using The Spring Framework?
Hibernate can be accessed inside the following two approaches:
By IOC with a Callback and HibernateTemplate.
By making use of an AOP Interceptor and broadening the HibernateDaoSupport.
Q29. What Is Sqlprovider?
SQLProvider has handiest one method known as getSql()and it's miles carried out the use of PreparedStatementCreator implementers. It is mainly used for debugging.
Q30. Define Bean Wiring?
Bean wiring is the creation of institutions among utility components which are between the beans in a particular spring container.
Q31. What Is Inner Bean? What Is The Drawback Of Inner Bean?
If a bean element is immediately embedded in a assets tag at the same time as wiring beans, then the bean is known as Inner Bean. Its downside is that it can't be reprocessed.
Q32. What Is The Web Module?
The web module allows the advent of an internet application without XML. The internet.Xml report desires to be configured for the use of the web module.
Q33. What Are The Various Channels Supported By Spring 2.Zero?
Following are the channels supported by way of spring version 2.0:
Pollable Channel
Subscribable Channel
PublishSubscribe Channel
Queue Channel
Priority Channel
Rendezvous Channel
Direct Channel
Executor Channel
Scoped Channel
Q34. Write The Benefits Of Using Ioc?
The main blessings of dependency injection or IOC are that it reduces the quantity of coding required for the application. This lets in the testing of the utility to be done quick and without difficulty as no JNDI lookup mechanism or singletons are required. IOC boxes additionally support lazy loading and eager installation of offerings.
Q35. What Is Autoproxying?
Autoproxying is used to create proxy automatically for the spring customers.
It affords following instructions to help this automatic proxy advent:
BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
Q36. What Are The Different Scopes Of Spring Bean?
Scopes of spring bean are Singleton, prototype, request, session and worldwide consultation.
Q37. Write About Core Container Module?
Core field module is chargeable for the fundamental functionality of the spring framework. The complete Spring framework is constructed with this module as a base.
Q38. Explain The Term Proxy?
The time period proxy refers to an object which is produced the application of an advice to the target item.
Q39. What Are Different Types Of Autowire?
There are 4 different styles of Auto wire:
byName
byType
constructor
autodetect
Q40. What Is Inversion Of Control (ioc)?
Inversion of Control (IOC) is likewise known as as dependency Injection that is nothingbut a layout pattern that gives control to the assembler of classes. In trendy, magnificence will instantiate any other elegance if required.
But in this layout sample, this manipulate has been to given to assembler and assembler will instantiate required class if wanted.
Q41. In What Points, Can Weaving Be Applied?
Following are the factors wherein weaving may be implemented:
Compile Time
Class load Time
Runtime
Q42. What Are The Types Of The Transaction Management That Is Supported By Spring?
Following are the types of transaction control that has been supported with the aid of spring:
declarative
programmatically
Q43. What Are The Different Types Of Autoproxying?
Following are the one-of-a-kind sorts of AutoProxying:
BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
Metadata autoproxying
Q44. State The Differences Between Applicationcontext And Beanfactory In Spring?
ApplicationContext lets in multiple config files to exist even as BeanFactory simplest permits one.
ApplicationContext can print activities to beans registered as listeners. This feature is not supported through BeanFactory.
ApplicationContext additionally affords support for software of lifecycle activities, internationalization messages and validation and additionally affords offerings like EJB integration, remoting, JNDI access and scheduling. These functions too are not supported by using Bean Factory.
Q45. What Is Called Spring Configuration File?
Spring configuration document is an XML document and it includes elegance statistics. It additionally describes how those lessons are configured and engage with every other.
Q46. What Is Metadata Autoproxying?
Metadata Autoproxying can be performed inspiring which may be driven by means of metadata. This is decided with the aid of source level attributes and maintains metadata inside the source code.
This keeps metadata in one region and specifically used for declarative transaction assist.
Q47. What Classes Are Used To Control The Database Connection?
Following are the lessons which can be used to manipulate database connection:
Data Source Utils
SmartData Source
AbstractData Source
SingleConnection DataSource
DriverManager DataSource
TransactionAware DataSourceProxy
DataSource TransactionManager
Q48. What Is Bean Factory?
Bean Factory is core of the spring framework and, it is a Lightweight box which hundreds bean definitions and manages your beans. Beans are configured the usage of XML record and control singleton described bean. It is also responsible for existence cycle techniques and injects dependencies. It additionally removes adhoc singletons and factories.
Q49. Define Application Context Module?
This is a totally vital module and elements diverse vital services like EJB integration, remoting, JNDI access and scheduling. It transforms spring into a framework. It additionally broadens the concept of BeanFactory by utility of lifecycle occasions, supplying guide for internationalization messages and validation.
Q50. What Is The Default Scope Of Bean In Spring Framework?
The default scope of bean is Singleton for Spring framework.

