Wednesday, April 24, 2019

Spring Interview Questions

Q- What is spring framework in java?

Q- What is advantages of Spring Framework? or What are the features of spring framework?

There are following the major features of Spring Framework:
  • Lightweight: Spring is lightweight in size and transparency. 
  • Inversion of control (IOC): Give the control to the container to create objects instead of creating object using new keyword and looking for dependent objects. This is called Inversion of Control.
  • Dependency Injection (DI): This feature of the Spring Framework allows us to build loosely coupled applications. its means inject the dependeny into the object.
  • Aspect oriented Programming (AOP): Aspect oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program. Aspect oriented programming in spring, supports cohesive development by separating application business logic from system services. In AOP, aspects enable to modularization of concerns such as transaction management, logging or security that cut across multiple types and objects (known as crosscutting concerns)
  • Container: The Spring IoC container is the core of the Spring Framework. The container will create the objects, wire them together, configure them, and manage their complete life cycle from creation till destruction. Type of spring containers – BeanFactory, ApplicationContext and WebApplicationContext.
  • MVC Framework:  Mvc is a spring module, Spring MVC is used to build web application. mvc framework is highly configurable. Its use DispatcherServlet as a front controller.   
  • Transaction Management: its generic abstraction layer. its use in transaction management provided by the Spring Framework. 
  • JDBC Exception Handling: The JDBC abstraction layer of spring framework offers an exception hierarchy, which help to simplify the error handling strategy.
  • Integration With Other Frameworks: its easy to work with other frame work. For example, this could include IBATIS, Hibernate, Toplink, etc.
Q- What is the difference between Spring MVC and spring framework?

Spring is a framework. This is used to connect different components together to build application or web application. Spring Framework is an open source framework and inversion of control container for the Java platform
The spring framework have many modules such as core, beans, context, expression language, AOP, Aspects, Instrumentation, JDBC, ORM, OXM, JMS, Transaction, Web, Servlet, Struts etc...

MVC (Model-View-Controller) is a spring module. Its implements the DispatcherServlet. DispatcherServlet work as front controller.   

Q- What is the spring bean lifecycle in java?
Answer : Spring Bean Lifecycle

Q- What are the different types of spring containers?
There are three type of containers in spring.
  • BeanFactory Container: This is the base contener. its parent of ApplicationContext.
  • ApplicationContext Container: Used to build non-web application. The ApplicationContext interface is built on top of the BeanFactory interface. It has extra functionality than BeanFactory. 
  • WebApplicationContext Container: used to create web application. WebApplicationContext has javax.servlet.ServletContext  it's able to communicate with the container.

Q- BeanFactory  Vs ApplicationContext  Vs WebApplicationContex ?

Q- Difference between ContextConfigLocation and ContextLoaderListener?
Q- What is the difference between DispatcherServlet and ContextLoaderListener in spring?
Q- Can we have multiple ApplicationContext in spring?
Q- Can we have more than one configuration file in Spring MVC?
Q- Can you have two bean ids in spring?
Q- Can we have two beans with same name in spring?
Q- What is difference between ID and name in spring?
Q- Can we have multiple dispatcher servlet in Spring MVC?
Q- What is root context in Spring MVC?
Q- Why spring bean scope is singleton by default?
Q- Is Singleton bean thread safe?
Q- What is the scope of stateless bean in spring?
Q- Are spring Services thread safe?

Q- How bean is created in spring?

Q- What should you know in spring? 
  • IoC Containers
  • IoC vs. DI
  • Bean Scopes
  • Bean Life Cycle
  • Bean Postprocessors
  • Autowiring
  • Autowire:  autodetect, byName, byType, constructor
  • ResourceLoader
  • Final Static Beans
  • Static Factory
  • FactoryBean
  • @Configuration
  • @Required
  • @Scheduled
  • Timer Task
  • JavaMailSenderImpl
  • Version-less Schema
  • Pub Sub
  • Best Practices
  • ResourceBundleMessageSource
  • CustomEditorConfigurer
  • @Component, @Repository, @Service and @Controller
Related Tutorials

No comments:

Post a Comment