Spring Core - Interview Questions

More Java interview questions and answers...

What is Spring Framework?

At its core, the Spring framework is genuinely just a dependency injection container, with a couple of convenience layers (database access, proxies, aspect-oriented programming, RPC, a web MVC framework) integrated on top. It avails us to build Java applications more expeditious and more conveniently.

What are the advantages of the spring framework?

  1. Solving difficulties of Enterprise application development
  2. Facile integration of other frameworks
  3. Support Enterprise application development through POJOs
  4. Modularity
  5. Lightweight
  6. Expeditious Development
  7. Facile to test
  8. Loose Coupling

What are the modules of the spring framework?

  1. Test
  2. Spring Core Container
  3. AOP, Aspects, and Instrumentation
  4. Data Access/Integration
  5. Web

What is the Dependency Injection?

Dependency Injection (DI) is a design pattern that is a fundamental aspect of the Spring framework, through which the Spring container "injects" objects into other objects. Simply put, this sanctions for loose coupling of components and moves the responsibility of managing components onto the container.

What is the IOC(inversion of control)? And the role of IOC container in spring?

Inversion of Control (IoC) is an object-oriented programing practice whereby the object coupling is bounded at runtime by an "assembler" object and is typically not knowable at compile time utilizing static analysis.

IOC container is responsible to:
  • engender the instance
  • configure the instance, and
  • assemble the dependencies

What are the types of IOC containers in spring?

  • BeanFactory
  • ApplicationContext

What is the bean factory in the spring framework?

The BeanFactory is the genuine container that instantiates, configures, and manages a number of beans. These beans typically collaborate with one another and thus have dependencies between themselves. These dependencies are reflected in the configuration data utilized by the BeanFactory.

What is the application context in the spring framework?

The ApplicationContext is the central interface within a Spring application that is utilized for providing configuration information to the application. It implements the BeanFactory interface. Hence, the ApplicationContext includes all functionality of the BeanFactory and much more!

ApplicationContext provides the following:
  • Bean factory methods for accessing application components
  • The facility to load file resources in a generic way
  • The faculty to publish events to registered listeners
  • The competency to resolve messages, fortifying internationalization

What is the difference between constructor injection and setter injection?

What is a Spring Bean?

Any java class that is initialized by the Spring IoC container is called Spring Bean. We utilize Spring ApplicationContext to get the Spring Bean instance.

Spring IoC container manages the life cycle of Spring Bean, bean scopes, and injecting any required dependencies in the bean.

What is the importance of the Spring bean configuration file?

We utilize the Spring Bean configuration file to define all the beans that will be initialized by Spring Context. When we engender the instance of Spring ApplicationContext, it reads the spring bean XML file and initializes all of them. Once the context is initialized, we can utilize it to get different bean instances.

What are different ways to configure a class as Spring Bean?

  1. XML Configuration
  2. Java Based Configuration
  3. Annotation Based Configuration

What do you understand by Aspect-Oriented Programming?

AOP is often defined as a technique that promotes disunion of concerns in a software system. Systems are composed of several components, each responsible for a categorical piece of functionality. But often these components withal carry additional responsibilities beyond their core functionality.
System services such as logging, transaction management, and security often find their way into components whose core responsibilities are something else. These system services are commonly referred to as cross-cutting concerns because they incline to cut across multiple components in a system.

Popular posts from this blog

Spring boot video streaming example-HTML5

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Spring Boot + Mockito simple application with 100% code coverage

Spring Boot + OpenCSV Export Data to CSV Example

Custom Exception Handling in Quarkus REST API

DataTable-Pagination example with Spring boot, jQuery and ajax

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Node JS mini projects with source code - free download

Spring boot web project free download:User Registration System

Spring Boot + Apache Commons Export Data to CSV Example