GeekZilla.io

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

50+ Spring Boot Interview Questions and Answers (2026)

spring boot interview questions

Spring Boot has become the go-to framework for building production-ready Java applications. Whether you are a fresher preparing for your first Java role or an experienced engineer targeting a senior position, interviewers consistently test Spring Boot knowledge across multiple domains — from auto-configuration basics to microservices design patterns.

This guide covers 50+ Spring Boot interview questions and
answers organised by difficulty and topic. Each answer is concise, technically
precise, and covers exactly what interviewers expect to hear in 2026.

Key Takeaways

1.    Questions are tiered: Sections 1–2 for freshers, Sections
3–4 for mid-level, Sections 5–6 for senior engineers.

2.    Answers include code snippets, annotation explanations,
and real-world context where relevant.

3.    Spring Boot 3.x-specific topics (Jakarta EE, virtual
threads, native images) are covered in Section 6.

4.    Microservices-related questions covering Spring Cloud,
Eureka, and Feign are included for architects and senior engineers.

Quick-Reference: Key Annotations & Concepts

Section

Topics
Covered

Best For

Section 1 —
Core Basics

Spring Boot
fundamentals, starters, annotations

Freshers &
entry-level (0–1 yr)

Section 2 —
Auto-Config & Beans

Auto-configuration,
IoC, dependency injection

Junior
developers (1–2 yrs)

Section 3 —
REST & Web

REST APIs,
controllers, request handling

Mid-level (2–4
yrs)

Section 4 —
Data & Persistence

Spring Data
JPA, repositories, transactions

Mid-level (2–4
yrs)

Section 5 —
Security & Testing

Spring
Security, OAuth2, unit/integration tests

Senior (4+ yrs)

Section 6 —
Microservices & Advanced

Microservices,
Actuator, Spring Boot 3.x

Senior/Architect
(5+ yrs)

Annotation
/ Concept

Purpose

@SpringBootApplication

Combines
@Configuration, @EnableAutoConfiguration, @ComponentScan

@RestController

Combines
@Controller + @ResponseBody; returns JSON/XML directly

@Autowired

Injects
dependency automatically by type

@Component /
@Service / @Repository

Stereotyped
Spring-managed beans with different semantic roles

@GetMapping /
@PostMapping / @PutMapping / @DeleteMapping

HTTP
method-specific shortcuts for @RequestMapping

@Entity

Marks a class
as a JPA entity mapped to a database table

@Transactional

Declares
transactional boundaries; rolls back on unchecked exceptions

@ConfigurationProperties

Binds
externalized properties to a POJO

@Profile

Activates a
bean or configuration only for a named profile

@EnableAutoConfiguration

Tells Spring
Boot to automatically configure beans based on classpath

Section 1: Spring Boot Core Basics (Freshers)

These questions cover foundational Spring Boot concepts
typically asked in entry-level and fresher interviews.

Q1. What is Spring Boot and how is it different from
Spring Framework?

Spring Framework is a comprehensive Java framework for
building enterprise applications, but it requires extensive XML or
annotation-based configuration. Spring Boot is built on top of Spring Framework
and eliminates most of this boilerplate through auto-configuration, starter
dependencies, and an embedded server. The key difference is that Spring Boot
follows ‘convention over configuration’ — you can get a production-ready
application running with minimal setup.

Q2. What are the main features of Spring Boot?

Spring Boot’s main features include:


Auto-configuration: automatically configures beans based on classpath
dependencies.


Starter POMs: pre-packaged dependency descriptors (e.g.,
spring-boot-starter-web) that pull in all required libraries.


Embedded servers: Tomcat, Jetty, or Undertow are embedded by default —
no need to deploy a WAR file.


Spring Boot Actuator: provides production-ready endpoints for health
checks, metrics, and monitoring.


Externalized configuration: properties can be managed through
application.properties or application.yml.

Q3. What is @SpringBootApplication and what annotations
does it combine?

@SpringBootApplication is a convenience annotation that
combines three annotations:


@Configuration: marks the class as a source of bean definitions.


@EnableAutoConfiguration: enables Spring Boot’s auto-configuration
mechanism.


@ComponentScan: scans the current package and sub-packages for
components.

@SpringBootApplication

public class
MyApplication {

    public
static void main(String[] args) {


SpringApplication.run(MyApplication.class, args);

    }

}

Q4. What is a Spring Boot Starter?

A Spring Boot Starter is a curated set of dependency
descriptors that can be added to a project’s build file to get all the
libraries needed for a specific feature. For example, spring-boot-starter-web
includes Spring MVC, Jackson (JSON), and an embedded Tomcat server. Starters
follow the naming convention spring-boot-starter-{feature} and significantly
reduce dependency management complexity.

Q5. What is the difference between @Component, @Service,
@Repository, and @Controller?

All four are specialisations of @Component, meaning they
all result in Spring-managed beans. The differences are semantic and
functional:


@Component: generic stereotype for any Spring-managed component.


@Service: used for business logic layer; semantically indicates a
service class.


@Repository: used for the persistence layer; enables exception
translation (converting database exceptions to Spring’s DataAccessException
hierarchy).


@Controller: used for web MVC controllers; handles HTTP requests and
returns view names.

Q6. What is the embedded server in Spring Boot and why is
it useful?

Spring Boot embeds a web server (Tomcat by default, with
Jetty and Undertow as alternatives) directly into the packaged JAR. This
eliminates the need to deploy WAR files to an external application server. The
embedded server simplifies development, testing, and deployment — particularly
in cloud and containerised environments. You can switch from Tomcat to Jetty by
excluding the default and adding the jetty starter.

Q7. What is the difference between application.properties
and application.yml?

Both files serve the same purpose — externalising
application configuration — but have different syntax. application.properties
uses a flat key=value format, while application.yml uses a hierarchical,
indentation-based YAML format. YAML is generally preferred for complex
configurations because it reduces repetition through hierarchy. Spring Boot
supports both and loads them automatically from the classpath.

Q8. How do you run a Spring Boot application?

A Spring Boot application can be run in several ways:


From the IDE: run the main() method of the @SpringBootApplication class.


From the command line using Maven: mvn spring-boot:run


From the command line using Gradle: ./gradlew bootRun


As a packaged JAR: java -jar my-application.jar

Section 2: Auto-Configuration, IoC, and Dependency Injection

Q9. What is Spring Boot auto-configuration and how does
it work?

Auto-configuration automatically configures Spring beans
based on the libraries present on the classpath. Spring Boot uses the
@EnableAutoConfiguration annotation (included in @SpringBootApplication) to
trigger this. Internally, Spring Boot scans META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
(Spring Boot 3.x) or spring.factories (Spring Boot 2.x) to find
auto-configuration classes. Each class uses @Conditional annotations to only
activate when certain conditions are met — for example, @ConditionalOnClass
checks that a specific class is on the classpath.

Q10. What is the difference between @Bean and @Component?

@Component is used on a class and allows Spring to detect
and register it via classpath scanning. @Bean is used on a method inside a
@Configuration class to explicitly define a bean. Use @Bean when you need to
configure a third-party class that you cannot annotate directly with
@Component, or when you need fine-grained control over bean instantiation.

Q11. What is dependency injection and what are its types
in Spring?

Dependency injection (DI) is a design pattern in which an
object’s dependencies are provided externally rather than created by the object
itself. Spring supports three types:


Constructor injection: dependencies are provided via a constructor
(generally preferred as it ensures immutability and mandatory dependencies).


Setter injection: dependencies are provided via setter methods (useful
for optional dependencies).


Field injection: dependencies are injected directly into fields using
@Autowired (convenient but makes testing harder; less recommended).

Q12. What is @Autowired and how does Spring resolve
ambiguity?

@Autowired instructs Spring to automatically inject a
dependency. When multiple beans of the same type exist, Spring cannot resolve
the dependency automatically. Ambiguity can be resolved using:


@Qualifier(“beanName”): specifies which bean to inject by
name.


@Primary: marks one bean as the default when multiple candidates exist.

Q13. What is the Spring IoC container?

The IoC (Inversion of Control) container is the core of the
Spring Framework. It is responsible for creating, configuring, and managing the
lifecycle of beans. The primary implementations are BeanFactory (lightweight,
lazy) and ApplicationContext (feature-rich, eager initialisation). Spring Boot
uses AnnotationConfigServletWebServerApplicationContext as its primary
ApplicationContext for web applications.

Q14. What is the difference between @Configuration and
@Component?

Both result in Spring-managed beans, but @Configuration has
additional behaviour: Spring creates a CGLIB subclass of @Configuration classes
to intercept @Bean method calls and ensure that each bean is a singleton (i.e.,
calling the method multiple times returns the same bean instance). @Component
does not have this interception, so calling a @Bean-annotated method from
another @Bean method in a @Component class may create a new instance each time.

Q15. What is @ConditionalOnProperty and when would you
use it?

@ConditionalOnProperty activates a bean or configuration
class only if a specified property is present and optionally matches a given
value. It is commonly used in library code and auto-configurations to allow
users to enable or disable features through application.properties.

@Bean

@ConditionalOnProperty(name
= “feature.email.enabled”, havingValue = “true”)

public
EmailService emailService() {

    return new
EmailService();

}

Section 3: REST APIs and Web Layer

Q16. What is the difference between @Controller and
@RestController?

@Controller is used to mark a class as an MVC controller
that typically returns view names for rendering. @RestController combines
@Controller and @ResponseBody, meaning every method’s return value is
automatically serialised to JSON or XML and written directly to the HTTP
response body. @RestController is the standard choice for building RESTful
APIs.

Q17. What is the difference between @RequestParam and
@PathVariable?

@PathVariable extracts a value from the URI path itself:
/users/{id}. @RequestParam extracts a query parameter from the URL:
/users?id=5. Both are used in controller methods, but path variables are
typically used for identifying a resource while query parameters are used for
filtering, sorting, or pagination.

// Path
variable: GET /users/42

@GetMapping(“/users/{id}”)

public User
getUser(@PathVariable Long id) { … }

// Query param:
GET /users?page=2

@GetMapping(“/users”)

public
List<User> getUsers(@RequestParam int page) { … }

Q18. What is ResponseEntity and when should you use it?

ResponseEntity is a wrapper that allows full control over
the HTTP response, including the status code, headers, and body. It is used
when you need to return custom HTTP status codes, add response headers, or
conditionally return different response bodies.

@GetMapping(“/users/{id}”)

public
ResponseEntity<User> getUser(@PathVariable Long id) {

    return
userService.findById(id)


.map(user -> ResponseEntity.ok(user))


.orElse(ResponseEntity.notFound().build());

}

Q19. What is @ExceptionHandler and @ControllerAdvice used
for?

@ExceptionHandler marks a method as a handler for a
specific exception type. When placed inside a @Controller, it handles
exceptions from that controller only. @ControllerAdvice (or
@RestControllerAdvice for REST APIs) makes the exception handlers global — they
apply to all controllers across the application. This is the standard pattern
for centralised exception handling.

Q20. What is the difference between @RequestMapping and
@GetMapping?

@RequestMapping is a general-purpose annotation that can
handle any HTTP method (GET, POST, PUT, DELETE, etc.) and accepts a method
attribute to specify the HTTP verb. @GetMapping is a shortcut annotation
equivalent to @RequestMapping(method = RequestMethod.GET). Method-specific
annotations (@GetMapping, @PostMapping, @PutMapping, @DeleteMapping,
@PatchMapping) are generally preferred for clarity and brevity in modern Spring
Boot code.

Section 4: Spring Data JPA and Persistence

Q21. What is Spring Data JPA and how does it simplify
database access?

Spring Data JPA is a sub-project of Spring Data that
simplifies JPA-based repository implementations. By extending JpaRepository or
CrudRepository, you get CRUD operations, pagination, and sorting out of the box
— with no implementation code required. Spring Data JPA generates the
implementation at runtime based on the interface definition and method naming
conventions.

Q22. What is the difference between CrudRepository and
JpaRepository?

CrudRepository provides basic CRUD operations (save,
findById, findAll, delete). PagingAndSortingRepository extends it with
pagination and sorting. JpaRepository extends PagingAndSortingRepository and
adds JPA-specific operations such as flush(), saveAndFlush(), and
deleteInBatch(). JpaRepository is typically used in Spring Boot applications as
it provides the most functionality.

Q23. What is a derived query method in Spring Data JPA?

Spring Data JPA can generate query implementations
automatically from method names following a specific naming convention. For
example:

// Spring Data
generates: SELECT * FROM users WHERE email = ?1

List<User>
findByEmail(String email);

// Multiple
conditions

List<User>
findByFirstNameAndLastName(String firstName, String lastName);

The method name is parsed and translated into a JPQL query
at startup. Supported keywords include: findBy, countBy, existsBy, deleteBy,
And, Or, Between, LessThan, GreaterThan, Like, OrderBy, etc.

Q24. What is @Transactional and when should you use it?

@Transactional declares the transactional semantics of a
method or class. Spring creates a proxy around the annotated method and manages
the transaction lifecycle (begin, commit, rollback). By default, Spring only
rolls back on unchecked exceptions (RuntimeException and Error). If you need
rollback on checked exceptions, use @Transactional(rollbackFor =
Exception.class). It is typically applied at the service layer, not the
repository layer (Spring Data repositories already apply @Transactional
internally).

Q25. What is the N+1 query problem and how do you solve
it in Spring Data JPA?

The N+1 problem occurs when fetching a list of N entities
triggers N additional queries to load each entity’s associations. It typically
happens with lazy-loaded @OneToMany or @ManyToMany relationships. Solutions
include:


FETCH JOIN in JPQL: @Query(“SELECT o FROM Order o JOIN FETCH
o.items”)


@EntityGraph: declaratively specifies which associations to eagerly load
for a specific query.


Batch fetching using Hibernate’s @BatchSize annotation on the
association.


Using DTO projections to select only the columns needed.

Q26. What is the difference between save() and
saveAndFlush() in JpaRepository?

save() persists or merges an entity and returns the saved
entity, but the change may not be immediately written to the database — it
depends on the transaction and Hibernate’s flush mode. saveAndFlush()
immediately flushes the pending changes to the database within the current
transaction. saveAndFlush() is useful when you need the database state to be
consistent within the same transaction before performing additional queries.

Section 5: Security, Testing, and Profiles

Q27. What is Spring Security and how do you add it to a
Spring Boot application?

Spring Security is a framework that provides
authentication, authorisation, and protection against common attacks (CSRF,
session fixation, etc.). Adding spring-boot-starter-security to your project
enables a default security configuration that secures all endpoints and
generates a random password on startup. You typically extend
WebSecurityConfigurerAdapter (Spring Boot 2.x) or create a SecurityFilterChain
bean (Spring Boot 3.x) to customise authentication and authorisation rules.

Q28. What is the difference between authentication and
authorisation?

Authentication verifies who a user is — it answers ‘Are you
who you claim to be?’ Authorisation determines what an authenticated user is
allowed to do — it answers ‘Do you have permission to access this resource?’ In
Spring Security, authentication is handled by AuthenticationManager and
authorisation is handled by AccessDecisionManager or the method security
annotations (@PreAuthorize, @Secured).

Q29. What is JWT and how is it typically used in Spring
Boot?

JWT (JSON Web Token) is a compact, URL-safe token format
used for stateless authentication. After a successful login, the server issues
a signed JWT containing the user’s identity and roles. The client includes this
token in the Authorization header (Bearer {token}) on subsequent requests. The
server validates the signature without needing to query a session store. In
Spring Boot, JWT is typically implemented using Spring Security with a custom
filter that intercepts requests, validates the token, and sets the
SecurityContext.

Q30. How do you write unit tests for a Spring Boot
application?

Spring Boot supports two main test approaches:


Unit tests (no Spring context): use JUnit 5 and Mockito to test
individual classes in isolation. Mock dependencies with @Mock and inject them
with @InjectMocks or constructor injection.


Integration tests (with Spring context): use @SpringBootTest to load a
partial or full application context. @WebMvcTest loads only the web layer
(controller tests). @DataJpaTest loads only the JPA layer.

@WebMvcTest(UserController.class)

class
UserControllerTest {

    @Autowired

    private
MockMvc mockMvc;

    @MockBean

    private
UserService userService;

}

Q31. What is @MockBean and how is it different from
Mockito’s @Mock?

@Mock (Mockito) creates a plain mock object that is used in
pure unit tests with no Spring context. @MockBean (Spring Boot Test) creates a
Mockito mock and registers it as a Spring bean in the application context,
replacing any existing bean of the same type. @MockBean is used in
@SpringBootTest, @WebMvcTest, and @DataJpaTest contexts where the Spring
context is loaded.

Q32. What are Spring Profiles and how do you use them?

Spring Profiles allow you to define sets of beans and
configurations that are only active in specific environments. You activate a
profile using the spring.profiles.active property or the SPRING_PROFILES_ACTIVE
environment variable. Profile-specific property files follow the naming
convention application-{profile}.properties. The @Profile annotation on a bean
or configuration class restricts it to the specified profile.

#
application-dev.properties

spring.datasource.url=jdbc:h2:mem:devdb

# Activate from
command line

java -jar
app.jar –spring.profiles.active=dev

Section 6: Microservices, Actuator & Spring Boot 3.x

These questions target senior engineers, architects, and
candidates interviewing for microservices or cloud-native roles.

Q33. What is Spring Boot Actuator and what does it
provide?

Spring Boot Actuator adds production-ready features to
applications through built-in HTTP endpoints. Key endpoints include:


/actuator/health: application health status (useful for load balancers
and container orchestration).


/actuator/metrics: application and JVM metrics (integrates with
Micrometer and Prometheus).


/actuator/info: arbitrary application info configured via
application.properties.


/actuator/env: lists all configuration properties and their values.


/actuator/loggers: allows changing log levels at runtime without
restarting.

By default, only /health and /info are exposed over HTTP.
Others must be explicitly enabled in application.properties.

Q34. What is the difference between
@SpringBootTest(webEnvironment = MOCK) and RANDOM_PORT?

MOCK (default) loads a WebApplicationContext with a mocked
servlet environment — no real HTTP server is started. Tests use MockMvc to
simulate HTTP requests. RANDOM_PORT starts a real embedded server on a random
port, and tests can use TestRestTemplate or WebTestClient to make real HTTP
calls. RANDOM_PORT is used for full integration tests; MOCK is faster and
sufficient for most controller tests.

Q35. What is Spring Cloud and how does it relate to
Spring Boot?

Spring Cloud is a suite of tools built on top of Spring
Boot that provides solutions for common distributed systems challenges: service
discovery (Eureka), client-side load balancing (Spring Cloud LoadBalancer),
circuit breakers (Resilience4j), API gateways (Spring Cloud Gateway), and
distributed configuration (Spring Cloud Config). Spring Boot provides the
foundation; Spring Cloud adds the cloud-native patterns on top.

Q36. What is a Circuit Breaker pattern and how is it
implemented in Spring Boot?

The Circuit Breaker pattern prevents cascading failures in
distributed systems by detecting when a downstream service is failing and
short-circuiting calls to it. In Spring Boot, this is typically implemented
using Resilience4j (the recommended library since Hystrix was deprecated). The
@CircuitBreaker annotation wraps a method call, and when the failure threshold
is reached, the circuit ‘opens’ and calls are redirected to a fallback method.

Q37. What is service discovery and how does Eureka work
with Spring Boot?

Service discovery allows microservices to find each other
by name rather than by hardcoded IP and port. Netflix Eureka is a service
registry: each microservice registers itself with Eureka on startup and queries
Eureka when it needs to call another service. In Spring Boot, you add
@EnableEurekaServer to the registry application and @EnableDiscoveryClient (or
@EnableEurekaClient) to service applications. Spring Cloud LoadBalancer uses
the registry to resolve service names to instances.

Q38. What are the major changes in Spring Boot 3.x?

Spring Boot 3.0 (released November 2022) and subsequent 3.x
versions introduced several significant changes:


Minimum requirement: Java 17 and Spring Framework 6.x.


Jakarta EE migration: all javax.* imports replaced with jakarta.* (e.g.,
javax.servlet becomes jakarta.servlet).


Native image support: first-class support for GraalVM native images via
spring-boot-starter-parent and the Spring AOT engine.


Observation API: Micrometer Observation API replaces separate tracing
and metrics APIs.


Virtual threads (Spring Boot 3.2+): opt-in support for Java 21 virtual
threads via spring.threads.virtual.enabled=true.


Problem Details (RFC 7807): built-in support for structured error
responses.

Q39. What is the difference between
@EnableAutoConfiguration and spring.factories / AutoConfiguration.imports?

In Spring Boot 2.x, auto-configuration classes were
registered in META-INF/spring.factories under the key EnableAutoConfiguration.
Spring Boot 3.x migrated to a new file: META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports.
This change improves startup performance by using a dedicated file that is read
more efficiently. The @EnableAutoConfiguration annotation itself still triggers
the mechanism, but the discovery file format changed.

Q40. What is the Spring Boot DevTools and what does it
provide?

Spring Boot DevTools (spring-boot-devtools) provides
development-time features that improve the developer experience:


Automatic restart: triggers a fast application restart when classpath
files change, using two classloaders (base and restart).


LiveReload: automatically refreshes the browser when resources change.


Property overrides: sets sensible development defaults (e.g., disables
template caching).

DevTools is automatically disabled when running a packaged
JAR, so it does not affect production deployments.

Section 7: Additional Frequently Asked Questions

Q41. What is @ConfigurationProperties and how is it
different from @Value?

@Value injects individual property values using SpEL
expressions: @Value(“${server.port}”). @ConfigurationProperties binds
a group of related properties to a POJO, making it easier to manage and
validate. @ConfigurationProperties is generally preferred when you have
multiple related settings, as it provides type safety, IDE auto-completion, and
supports bean validation with @Validated.

Q42. What is lazy initialisation in Spring Boot and how
do you enable it?

By default, Spring Boot initialises all beans eagerly at
startup. Lazy initialisation delays bean creation until the bean is first
requested. This can improve startup time. Enable it globally with
spring.main.lazy-initialization=true or selectively on individual beans with
@Lazy. The trade-off is that potential configuration errors are not detected at
startup but may appear at request time.

Q43. What is the difference between a fat JAR and a WAR
in Spring Boot?

A fat JAR (also called an uber JAR or executable JAR)
contains the application code, all dependencies, and an embedded server —
everything needed to run independently with java -jar. A WAR (Web Application
Archive) is a traditional deployment package that excludes the embedded server
and is deployed to an external application server. Spring Boot supports both
formats, but fat JARs are generally preferred for cloud-native and
microservices deployments.

Q44. How does Spring Boot handle externalized
configuration priority?

Spring Boot loads configuration from multiple sources in a
defined priority order (highest to lowest):


Command-line arguments (–server.port=8081)


OS environment variables


application-{profile}.properties or .yml (profile-specific files)


application.properties or application.yml (default files)


@PropertySource annotations


Default values in @Value or @ConfigurationProperties

Higher-priority sources override lower-priority ones. This
layered approach allows configuration to be customised without modifying the packaged
artifact.

Q45. What is Spring Boot’s banner and can it be
customised?

Spring Boot prints an ASCII art banner to the console at
startup. You can customise it by adding a banner.txt file to
src/main/resources. The banner can include version variables like
${spring-boot.version}. To disable the banner: SpringApplication.setBannerMode(Banner.Mode.OFF)
or set spring.main.banner-mode=off in application.properties. While the banner
is largely cosmetic, it is a commonly asked question in introductory
interviews.

Q46. What is @Scheduled and how do you enable scheduling
in Spring Boot?

@Scheduled marks a method to be executed on a fixed
schedule. Scheduling must be enabled by adding @EnableScheduling to a
configuration class. Supported scheduling options include fixedRate,
fixedDelay, and cron expressions.

@EnableScheduling

@SpringBootApplication

public class
MyApp { … }

@Scheduled(cron
= “0 0 9 * * MON-FRI”)

public void
sendDailyReport() { … }

Q47. What is Spring Boot’s support for caching?

Spring Boot provides a caching abstraction through the
spring-cache module. Enable caching with @EnableCaching on a configuration
class. Use @Cacheable on methods to cache their return values, @CachePut to
update the cache, and @CacheEvict to remove entries. Spring Boot
auto-configures a suitable CacheManager based on available providers (EhCache,
Redis, Caffeine, Hazelcast, etc.). If none is found, a simple in-memory
ConcurrentMapCacheManager is used.

Q48. What is the purpose of SpringApplication.run()?

SpringApplication.run() bootstraps and launches the Spring
Boot application. It creates an ApplicationContext, applies auto-configuration,
registers all beans, starts the embedded server, and publishes application
lifecycle events (ApplicationStartedEvent, ApplicationReadyEvent, etc.). It
returns the fully configured ApplicationContext, which can be used to inspect
the bean registry if needed.

Q49. What is a BeanFactory vs ApplicationContext?

BeanFactory is the root interface of the Spring IoC
container, providing basic dependency injection. ApplicationContext extends
BeanFactory and adds enterprise-specific features: event publishing, i18n
message resolution, resource loading, AOP support, and web context management.
Spring Boot always uses ApplicationContext (specifically
AnnotationConfigServletWebServerApplicationContext for web applications), and
BeanFactory is rarely used directly.

Q50. How do you implement pagination in Spring Boot with
Spring Data JPA?

Spring Data JPA supports pagination out of the box through
the Pageable interface. Pass a Pageable parameter to a repository method and
Spring Data generates the appropriate SQL with LIMIT and OFFSET.

Page<User>
findByStatus(String status, Pageable pageable);

// In service
layer:

Pageable page =
PageRequest.of(0, 20, Sort.by(“lastName”).ascending());

Page<User>
result = userRepository.findByStatus(“ACTIVE”, page);

result.getContent();
// list of users

result.getTotalElements();
// total count

result.getTotalPages();
// number of pages

Q51. What is Spring Boot’s support for reactive
programming?

Spring Boot supports reactive programming through Spring
WebFlux, included via spring-boot-starter-webflux. WebFlux is built on Project
Reactor and uses non-blocking I/O with Netty as the default server. Controllers
use Mono<T> (0–1 elements) and Flux<T> (0–N elements) instead of
plain return types. Reactive programming is beneficial for high-concurrency,
I/O-bound workloads, but adds complexity and is not necessary for most standard
CRUD applications.

Interview Tips: What Interviewers Are Really Looking For

Tip: Interviewers for mid-senior roles often care less
about memorised definitions and more about your ability to explain trade-offs.
For example: ‘When would you use reactive WebFlux vs standard Spring MVC?’ or
‘Why is constructor injection preferred over field injection?’ Always connect
your answers to real-world consequences.


Explain not just what a feature is, but when and why you would use it.


Mention trade-offs — every technology choice has pros and cons.


Reference real project experience where possible to make answers
concrete.


For security questions, always address both authentication AND
authorisation.


For microservices questions, be prepared to discuss failure scenarios
and resilience patterns.

Conclusion

Preparing for Spring Boot interview questions requires a solid
understanding of the framework across multiple layers — from IoC and
auto-configuration basics to REST API design, JPA persistence, security, and
microservices patterns. The questions covered in this guide reflect the breadth
of topics that interviewers test across all experience levels in 2026.

For freshers, focus on Sections 1 and 2. For mid-level
developers, deepen your understanding of Sections 3, 4, and 5. For senior roles
and architect positions, ensure you can discuss Sections 6 and 7 with
confidence, including Spring Boot 3.x changes and microservices design
patterns.

Practice explaining your answers out loud. The ability to
communicate technical concepts clearly is as important as the accuracy of the
answer in a live interview setting.

Picture of Johnathan Dale
Johnathan Dale

John is a cheerful and adventurous boy, loves exploring nature and discovering new things. Whether climbing trees or building model rockets, his curiosity knows no bounds.

Newsletter

Register now to get latest updates on promotions & coupons.