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.

Comments

Popular posts from this blog

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

Java, Spring Boot Mini Project - Library Management System - Download

Java - DES Encryption and Decryption example

Java - Blowfish Encryption and decryption Example

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete

ReactJS - Bootstrap - Buttons

Top 5 Java ORM tools - 2024

Spring Boot 3 + Spring Security 6 + Thymeleaf - Registration and Login Example

File Upload, Download, And Delete - Azure Blob Storage + Spring Boot Example

Java - How to Count the Number of Occurrences of Substring in a String