Auto-configuration • Beans & DI • REST • Spring Data JPA • Security • 2026

Spring Boot Interview Questions

30 questions What each one tests, an answer frame, a spoken answer 35 min read

This page is for Java developers facing a Spring Boot round, from a first backend job to a senior role. Most interviews start with what Boot adds to Spring, auto-configuration and starters, then move to beans, scopes and dependency injection, configuration and profiles, and how a request reaches a REST controller. The hardest part is usually Spring Data JPA: N+1 queries, lazy loading and why @Transactional sometimes does nothing. Expect Spring Security, Actuator and testing too, and in senior rounds a production story and a judgement call. Each question shows what the interviewer is checking and an answer you can say out loud.

Search all questions by round, difficulty and level, or save the ones you want to practise.

Core & Auto-Config 4 questions

Easy Technical round Fresher Practice question

1. What does Spring Boot actually add on top of the Spring Framework? Why not just use plain Spring?

What the interviewer is really testing:
Whether you see Boot as opinionated defaults around the same Spring core, rather than a separate framework you can't explain.
Answer frame:

Same core: Boot still uses Spring's container, MVC, Data and Security; it doesn't replace them.

Defaults: auto-configuration builds the usual beans from what's on the classpath and in your properties.

Packaging: starters manage compatible versions, and an embedded server lets you run one executable jar.

Production: externalised config, profiles and Actuator come built in.

Sample spoken answer:

"Spring Boot isn't a different framework, it's Spring with sensible defaults. With plain Spring I'd configure the DispatcherServlet, a DataSource, a transaction manager, Jackson and a server myself, and pick library versions that work together. Boot does most of that for me. Starters bring in a tested set of dependencies, auto-configuration looks at what's on the classpath and what I've set in my properties and creates the beans I'd normally write by hand, and the embedded server means I build one jar and run it with java -jar. On top of that I get externalised configuration, profiles and Actuator for health checks and metrics. The key point is that every default backs off as soon as I define my own bean, so I keep full control when I need it."

Red flag to avoid:

Describing Boot as a replacement for Spring, or saying it removes configuration rather than supplying defaults you can override.

They may ask next:
  • What does "backs off" mean in practice when you define your own DataSource bean?
  • Can you still deploy a Spring Boot app as a WAR to an external server, and why might you?
Say it in 60 seconds
Medium Technical round Mid-level, Senior Practice question

2. How does auto-configuration decide which beans to create, and how do you find out why a bean was or wasn't created?

What the interviewer is really testing:
Whether you can debug Boot's "magic" instead of guessing, which is what you need when a default bean shows up that you didn't expect.
Answer frame:

Discovery: Boot reads a list of auto-configuration classes that each starter jar registers.

Conditions: each class is guarded by conditions such as @ConditionalOnClass, @ConditionalOnMissingBean and @ConditionalOnProperty.

Debugging: run with --debug, or use the Actuator conditions endpoint, to see the evaluation report.

Control: define your own bean, set a property, or exclude an auto-configuration class.

Sample spoken answer:

"At startup, @EnableAutoConfiguration loads a list of auto-configuration classes that the jars on the classpath register. Every one of those classes is guarded by conditions. For example, the DataSource configuration only applies when the JDBC classes are on the classpath, and it only creates a DataSource if I haven't defined one myself, which is @ConditionalOnMissingBean. Others check a property with @ConditionalOnProperty. So what I get depends on my dependencies, my properties and my own beans. When something surprises me, I start the app with --debug and Boot prints a conditions evaluation report: which auto-configurations matched and why the others didn't. With Actuator there's a conditions endpoint that shows the same thing. To switch one off completely, I use the exclude attribute on @SpringBootApplication or the spring.autoconfigure.exclude property."

Code:
@AutoConfiguration
@ConditionalOnClass(ObjectMapper.class)
public class AuditAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean
    AuditClient auditClient(ObjectMapper mapper) {
        return new AuditClient(mapper); // skipped if the app defines its own AuditClient
    }
}
Red flag to avoid:

Saying Boot scans the whole classpath and creates every bean it can, or having no way to find out why a bean exists.

They may ask next:
  • How would you write your own auto-configuration for a shared library, and how does Boot find it?
  • Why does the order between auto-configurations matter for @ConditionalOnMissingBean?
Say it in 60 seconds
Easy Technical round Fresher, Mid-level Practice question

3. What is a Spring Boot starter? What do you actually get when you add spring-boot-starter-web?

What the interviewer is really testing:
Whether you know a starter is a curated set of dependencies with managed versions, and can say what lands in your app when you add one.
Answer frame:

Definition: a starter is a dependency descriptor that pulls in a working set of libraries, with little or no code of its own.

Web example: Spring MVC, Jackson for JSON, an embedded Tomcat, and the core starter with logging and auto-configuration.

Versions: the Boot parent or BOM fixes compatible versions, so you rarely write version numbers.

Sample spoken answer:

"A starter is mostly just a dependency descriptor. It has little or no code of its own; it pulls in a set of libraries that are known to work together. When I add spring-boot-starter-web, I get Spring MVC, Jackson for turning objects into JSON, an embedded Tomcat server, and the core starter, which brings logging and auto-configuration. Because those jars are now on the classpath, auto-configuration sets up the DispatcherServlet, the JSON converters and the server for me. The versions come from Boot's dependency management, through the parent pom or the BOM, so I don't list a version for each library and I don't end up with clashing ones. If I wanted Jetty instead of Tomcat, I'd exclude the Tomcat starter and add the Jetty one."

Red flag to avoid:

Thinking a starter holds the configuration code itself, or overriding managed versions casually without checking compatibility.

They may ask next:
  • What's the difference between using the Boot parent pom and importing the Boot BOM?
  • When would you override a version that Boot manages, and what's the risk?
Say it in 60 seconds
Easy Technical round Fresher Practice question

4. What does @SpringBootApplication do? What goes wrong if your controller sits outside the main class's package?

What the interviewer is really testing:
Whether you know the three annotations it combines, and can explain the common "my bean isn't found" bug that comes from component scanning.
Answer frame:

Three in one: @SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan.

Scan root: scanning starts from the main class's package and goes down into its sub-packages.

Symptom: a class in a sibling package is silently skipped, so you get a 404 or a missing bean error.

Sample spoken answer:

"@SpringBootApplication is a shortcut for three annotations. @SpringBootConfiguration marks the class as a configuration class, @EnableAutoConfiguration turns on Boot's auto-configuration, and @ComponentScan finds my components. The scan starts from the package the main class is in and walks down through its sub-packages. So if my main class is in com.shop.app and I put a controller in com.shop.web, it's outside the scan and Spring never registers it. There's no error about the controller itself; I just get a 404 for its endpoints, or an unsatisfied dependency error if another bean needs it. The clean fix is to put the main class in the root package of the project. I could set scanBasePackages instead, but moving the class is simpler and keeps things predictable."

Red flag to avoid:

Not knowing that scanning starts from the main class's package, or fixing it by scattering extra @ComponentScan annotations around.

They may ask next:
  • Would JPA entities and repositories also be affected by where the main class sits?
  • Why is putting the main class in the default package a bad idea?
Say it in 60 seconds

Beans & DI 5 questions

Easy Technical round Fresher, Mid-level Practice question

5. What is dependency injection in Spring, and why do most teams prefer constructor injection over @Autowired on fields?

What the interviewer is really testing:
Whether you understand inversion of control as a design idea and can defend constructor injection with concrete reasons, not just habit.
Answer frame:

IoC: the container creates objects and hands them their dependencies; the class doesn't build them.

Constructor wins: fields can be final, required dependencies are explicit, and missing ones fail at startup.

Testing: you can build the class with plain new and mocks, no Spring context needed.

Smell check: a constructor with many parameters tells you the class does too much.

Sample spoken answer:

"Inversion of control means my class doesn't create its own dependencies. The Spring container builds the objects, works out what each one needs and passes it in; dependency injection is how it passes them in. I prefer constructor injection for a few reasons. The fields can be final, so the object is fully built and can't be half-wired. Required dependencies are right there in the signature, so a missing bean fails at startup. And in a unit test I can just call new OrderService with a mock repository, without starting Spring. If a class has only one constructor, Spring uses it automatically, so I don't even need @Autowired. Field injection hides dependencies, needs reflection or a Spring context to test, and makes it too easy to keep adding more. When a constructor grows to seven or eight parameters, that's my signal to split the class."

Code:
@Service
public class OrderService {
    private final OrderRepository orders;
    private final Clock clock;

    public OrderService(OrderRepository orders, Clock clock) { // no @Autowired needed
        this.orders = orders;
        this.clock = clock;
    }
}
Red flag to avoid:

Saying field injection is fine because it's shorter, or not knowing that a single constructor needs no @Autowired.

They may ask next:
  • Two beans implement the same interface. How does Spring decide which one to inject, and how do you tell it?
  • When would setter injection still make sense?
Say it in 60 seconds
Easy Technical round Fresher, Mid-level Practice question

6. @Component, @Service, @Repository, @Controller: are they just labels, or does Spring treat any of them differently?

What the interviewer is really testing:
Whether you know which stereotypes carry real behaviour, especially exception translation on @Repository, instead of calling them all identical.
Answer frame:

Base: all are @Component, so component scanning picks up every one of them.

@Repository: gets persistence exception translation into Spring's DataAccessException family.

@Controller: is detected as a web handler; @RestController adds @ResponseBody.

@Service: adds no behaviour today; it documents the layer.

Sample spoken answer:

"They're all specialisations of @Component, so component scanning registers any of them as a bean. The difference is partly meaning and partly behaviour. @Repository marks a data access class, and Spring can wrap it so database-specific exceptions are translated into its own DataAccessException hierarchy. That way my service layer doesn't depend on JDBC or JPA exception types. @Controller tells Spring MVC the class holds request handlers, and @RestController is @Controller plus @ResponseBody, so return values are written straight into the response body. @Service doesn't add behaviour at the moment; it just says this is business logic. I still use it because it makes the layers obvious and gives aspects or tooling something to target. So they're not purely labels, but @Service mostly is."

Red flag to avoid:

Saying they are completely interchangeable with no difference at all, or not knowing that @RestController implies @ResponseBody.

They may ask next:
  • Do you need @Repository on a Spring Data JPA repository interface? Why or why not?
  • Could you write your own stereotype annotation, and why would you?
Say it in 60 seconds
Medium Technical round Mid-level Practice question

7. What bean scopes does Spring support, and what happens when you inject a prototype-scoped bean into a singleton?

What the interviewer is really testing:
Whether you understand that the scope is applied at injection time, the classic trap that leaves a "prototype" behaving like a singleton.
Answer frame:

Scopes: singleton by default, prototype, and web scopes such as request and session.

The trap: a singleton is wired once, so it keeps the one prototype instance it got at startup.

Fixes: ask for a fresh instance through ObjectProvider or a @Lookup method, or use a scoped proxy.

Threads: singleton doesn't mean thread-safe; shared mutable state is still your problem.

Sample spoken answer:

"The default scope is singleton, meaning one instance per application context. Prototype means a new instance every time the container is asked for the bean. In a web app there are also request and session scopes. The trap is mixing them. If a singleton service gets a prototype bean through its constructor, injection happens once, when the singleton is created, so the service holds that same instance forever. It looks like a prototype but behaves like a singleton. To get a fresh one each time, I inject an ObjectProvider of that type and call getObject when I need it, or use a @Lookup method. For request-scoped beans used inside singletons, a scoped proxy does the job: the singleton holds a proxy that finds the current request's instance on every call. And I remind people that singleton scope says nothing about thread safety."

Code:
@Service
public class ReportService {
    private final ObjectProvider<ReportBuilder> builders;

    public ReportService(ObjectProvider<ReportBuilder> builders) {
        this.builders = builders;
    }

    public Report build(Order order) {
        ReportBuilder builder = builders.getObject(); // new prototype on every call
        return builder.from(order);
    }
}
Red flag to avoid:

Believing Spring hands the singleton a new prototype on every method call, or treating singleton scope as a promise of thread safety.

They may ask next:
  • Does Spring call @PreDestroy on prototype beans? Why not?
  • Is a singleton service thread-safe just because Spring manages it?
Say it in 60 seconds
Medium Technical round Mid-level Practice question

8. Walk me through a bean's lifecycle, from creation to shutdown. Where do @PostConstruct and BeanPostProcessors fit in?

What the interviewer is really testing:
Whether you know the order well enough to put startup logic in the right place and understand when proxies get created.
Answer frame:

Create and wire: instantiate, inject dependencies, then Aware callbacks.

Initialise: post-processors' before hooks, @PostConstruct, afterPropertiesSet, then the after hooks, where proxies are usually made.

Use: the bean serves calls while the context is running.

Destroy: on shutdown, @PreDestroy and destroy methods run for singletons.

Sample spoken answer:

"Spring first instantiates the bean, then injects its dependencies, then calls Aware interfaces like BeanNameAware if the class implements them. Next come the BeanPostProcessors. Their before-initialisation hook runs, then the init callbacks: @PostConstruct, then afterPropertiesSet if it implements InitializingBean, then any custom init method. Then the after-initialisation hook runs, and that's usually where Spring wraps the bean in a proxy for things like @Transactional or @Async. From there the bean is in use. On shutdown the context calls @PreDestroy, then destroy from DisposableBean, then any custom destroy method. That's for singletons; with prototypes Spring hands the object over and never destroys it. In practice I keep @PostConstruct light, and for work that needs the whole app ready I listen for ApplicationReadyEvent instead."

Red flag to avoid:

Putting heavy work or remote calls in @PostConstruct, or not knowing that proxies are applied after initialisation.

They may ask next:
  • Why might a @Transactional method called from @PostConstruct run without a transaction?
  • What would you use to run a task once the application has fully started?
Say it in 60 seconds
Hard Technical round Mid-level, Senior Practice question

9. Your app fails to start because two services depend on each other. Why does Spring refuse it, and how do you fix it properly?

What the interviewer is really testing:
Whether you treat a dependency cycle as a design problem to solve, not something to silence with a flag.
Answer frame:

Why it fails: with constructor injection neither bean can be built first; newer Boot versions also refuse field and setter cycles by default.

Real fix: move the shared logic into a third bean, or reverse one direction with an event.

Stopgaps: @Lazy on one injection point, or allowing circular references, used knowingly and briefly.

Sample spoken answer:

"If A needs B in its constructor and B needs A in its constructor, there's no order in which Spring can build them, so startup fails. With field or setter injection Spring used to get around it by exposing a half-built bean early, but newer Boot versions turn that off by default. I think that's right, because a cycle usually means two classes know too much about each other. My first step is to look at what each one actually uses from the other. Often both depend on a small piece of logic that belongs in its own bean, so I pull it out and the cycle disappears. Sometimes one direction is really a notification, so publishing an application event decouples it. @Lazy on one constructor parameter works as a short-term patch because it injects a proxy, but I'd leave a ticket to clean it up."

Red flag to avoid:

Reaching straight for spring.main.allow-circular-references, or switching to field injection just to hide the cycle.

They may ask next:
  • How does @Lazy break the cycle under the hood?
  • Can a cycle show up in production but not in your tests? How?
Say it in 60 seconds

Configuration 2 questions

Medium Technical round Mid-level Practice question

10. The same property is set in application.yml, an environment variable and a command-line argument. Which wins? And when do you use @ConfigurationProperties instead of @Value?

What the interviewer is really testing:
Whether you can predict where a value comes from in production and prefer typed, validated configuration over scattered strings.
Answer frame:

Order: command-line arguments beat environment variables, which beat values in application files.

Files: profile-specific files beat the default one, and files outside the jar beat those packaged inside.

Binding: relaxed binding maps SPRING_DATASOURCE_URL to spring.datasource.url.

Typed config: @ConfigurationProperties groups related settings into a validated class; @Value suits one-off values.

Sample spoken answer:

"Boot layers its property sources and the more specific one wins. A command-line argument beats an environment variable, and an environment variable beats whatever is in application.yml. Among the files, a profile-specific one like application-prod.yml overrides the plain one, and a file outside the jar overrides one packaged inside it. Relaxed binding means an environment variable called SPRING_DATASOURCE_URL sets spring.datasource.url, which is how most containers pass config in. For reading values, @Value is fine for a single setting. When I have a group, say a base URL, a timeout and a retry count for a payment client, I use @ConfigurationProperties with a prefix. I get one typed class, I can add @Validated so the app refuses to start with a bad value, and the IDE can autocomplete the keys. It's also far easier to test than strings spread through the code."

Code:
// register with @ConfigurationPropertiesScan on the main class
@Validated
@ConfigurationProperties(prefix = "payments.client")
public record PaymentClientProperties(
        @NotBlank String baseUrl,
        @NotNull Duration timeout,
        @Min(0) int maxRetries) {
}
Red flag to avoid:

Not knowing that environment variables override the packaged file, or committing production secrets into application.yml.

They may ask next:
  • How do you register a @ConfigurationProperties class so Boot binds it?
  • Where should a database password come from in production, if not the yml file?
Say it in 60 seconds
Easy Technical round Fresher, Mid-level Practice question

11. What are Spring profiles, and how would you set up different configuration for local, test and production?

What the interviewer is really testing:
Whether you can separate environments cleanly without branching in code, and keep secrets out of profile files.
Answer frame:

Activate: set spring.profiles.active through an environment variable or argument, not in code.

Files: application.yml holds shared defaults; application-prod.yml holds only what differs.

Beans: @Profile switches whole beans, like a fake email sender for local runs.

Secrets: come from the environment or a secret store, never from profile files in git.

Sample spoken answer:

"A profile is a named set of configuration and beans that's only active when I switch it on. I keep shared defaults in application.yml and put only the differences in files like application-local.yml or application-prod.yml: the database URL, log levels, feature flags. The profile is chosen outside the code, usually with the SPRING_PROFILES_ACTIVE environment variable in the deployment, so the same jar runs everywhere. For behaviour differences I use @Profile on beans. Locally I might register a fake email sender under the local profile and the real one under prod. I'm careful about two things. Passwords never go in a profile file; they come from environment variables or a secret manager. And I avoid lots of tiny profiles that combine in confusing ways, because then nobody can say what production is actually running."

Red flag to avoid:

Using if-statements on an environment name inside business code, or storing production credentials in application-prod.yml.

They may ask next:
  • How would you check which profiles and property values a running instance really has?
  • What happens if no profile is active at all?
Say it in 60 seconds

Web & REST 3 questions

Medium Technical round Mid-level Practice question

12. Walk me through what happens when an HTTP request hits a @RestController method, from the server to the JSON response.

What the interviewer is really testing:
Whether you understand the Spring MVC pipeline well enough to know where filters, interceptors, argument binding and JSON conversion happen.
Answer frame:

Entry: the embedded server runs the servlet filters, including Spring Security's, then hands off to the DispatcherServlet.

Routing: handler mappings find the controller method; interceptors' preHandle runs.

Binding: argument resolvers fill path variables, query params and the body through Jackson.

Response: a message converter writes the return value; exceptions go to exception resolvers.

Sample spoken answer:

"The request lands on the embedded server, Tomcat by default, which runs it through the servlet filter chain. Spring Security lives there as a filter, so authentication happens before any controller code. Then it reaches the DispatcherServlet, the front controller for Spring MVC. It asks the handler mappings which method matches the path and HTTP method, runs any interceptors' preHandle, and calls the method through a handler adapter. Before the call, argument resolvers fill in the parameters: @PathVariable and @RequestParam from the URL, and @RequestBody by passing the body to a message converter, which uses Jackson for JSON, with validation if I've added @Valid. Because it's a @RestController, the return value is written to the response by a message converter chosen from the Accept header. If anything throws, the exception resolvers take over, and that's where my @ControllerAdvice handlers get called."

Red flag to avoid:

Having no idea the DispatcherServlet exists, or thinking security checks happen inside the controller by default.

They may ask next:
  • When would you use a servlet filter rather than a HandlerInterceptor?
  • What decides whether the response comes back as JSON or XML?
Say it in 60 seconds
Medium Coding round Fresher, Mid-level Practice question

13. Write a REST endpoint that creates a customer from a JSON body, validates it and returns the right status code.

What the interviewer is really testing:
Whether you can write a clean, correct endpoint: validated input, a DTO instead of the entity, and 201 Created with a Location header.
Answer frame:

Input: a request DTO with validation annotations, bound with @Valid @RequestBody.

Work: hand off to a service so the controller stays thin.

Output: 201 Created with a Location header and a response DTO, not the JPA entity.

Failure: invalid input becomes a 400 automatically, which you shape in a global handler.

Sample spoken answer:

"I'd start with a request record, CreateCustomerRequest, with @NotBlank on the name and @Email on the email. The controller method takes it with @Valid and @RequestBody, so if validation fails Spring throws MethodArgumentNotValidException before my code runs and the client gets a 400. The controller only calls the service, which saves the customer and returns a response DTO. I don't return the entity itself, because that ties my API to the database model and can trigger lazy loading while Jackson writes the JSON. Since this creates a resource, I return 201 Created with a Location header pointing at the new customer's URL, built from the current request. One thing to remember: validation needs spring-boot-starter-validation on the classpath. Without it, @Valid quietly does nothing."

Code:
public record CreateCustomerRequest(@NotBlank String name, @NotBlank @Email String email) {}

@RestController
@RequestMapping("/customers")
public class CustomerController {
    private final CustomerService service;

    public CustomerController(CustomerService service) {
        this.service = service;
    }

    @PostMapping
    public ResponseEntity<CustomerResponse> create(@Valid @RequestBody CreateCustomerRequest req) {
        CustomerResponse created = service.create(req);
        URI location = ServletUriComponentsBuilder.fromCurrentRequest()
                .path("/{id}").buildAndExpand(created.id()).toUri();
        return ResponseEntity.created(location).body(created);
    }
}
Red flag to avoid:

Returning 200 with the JPA entity for a create, or validating by hand with if-statements inside the controller.

They may ask next:
  • How would you return a clear error body listing which fields failed validation?
  • What would you do if the client retries and the same create request arrives twice?
Say it in 60 seconds
Medium Coding round Mid-level Practice question

14. How do you handle exceptions across all controllers in one place, so every error response looks the same?

What the interviewer is really testing:
Whether you centralise error handling with @RestControllerAdvice, map exceptions to correct status codes, and avoid leaking internals.
Answer frame:

Central place: a @RestControllerAdvice class with @ExceptionHandler methods.

Mapping: not found to 404, conflicts to 409, validation to 400, everything else to 500.

Spring's own errors: extend ResponseEntityExceptionHandler so a catch-all doesn't turn a bad request into a 500.

Shape and safety: one format, such as ProblemDetail; full stack trace in the log, never in the response.

Sample spoken answer:

"I use a @RestControllerAdvice class, which applies to every controller, and give it @ExceptionHandler methods for each kind of failure. My own exceptions like CustomerNotFoundException map to 404, a duplicate email maps to 409, and a last handler for Exception returns a plain 500. I make the class extend ResponseEntityExceptionHandler, because otherwise that catch-all also grabs Spring's own exceptions, and a failed validation or broken JSON body comes back as a 500 instead of a 400. I override its validation hook to list the bad fields. For the body, recent Spring versions have ProblemDetail, which follows the standard problem details format for HTTP APIs, so clients always get the same structure: a status, a title and a detail. The client gets a safe, useful message, and the server log gets the full stack trace with a request id. A raw exception message or SQL error never reaches the response."

Code:
@RestControllerAdvice
public class ApiErrors extends ResponseEntityExceptionHandler { // keeps Spring's 4xx mappings
    private static final Logger log = LoggerFactory.getLogger(ApiErrors.class);

    @ExceptionHandler(CustomerNotFoundException.class)
    ProblemDetail notFound(CustomerNotFoundException ex) {
        return ProblemDetail.forStatusAndDetail(HttpStatus.NOT_FOUND, ex.getMessage());
    }

    @ExceptionHandler(Exception.class)
    ProblemDetail unexpected(Exception ex) {
        log.error("Unhandled error", ex);
        return ProblemDetail.forStatusAndDetail(HttpStatus.INTERNAL_SERVER_ERROR, "Something went wrong");
    }
}
Red flag to avoid:

Wrapping every controller method in its own try-catch, or returning stack traces and SQL messages in the response body.

They may ask next:
  • If two handlers could match the same exception, which one does Spring pick?
  • How would you handle an error thrown in a filter, before the request reaches any controller?
Say it in 60 seconds

Data & Transactions 7 questions

Medium Technical round Mid-level, Senior Practice question

15. What is the N+1 query problem in Spring Data JPA? How do you spot it and fix it?

What the interviewer is really testing:
Whether you have actually looked at the SQL your JPA code generates and know more than one fix, with trade-offs.
Answer frame:

Cause: one query loads N parents, then touching a lazy association fires one more query per parent.

Spot it: turn on SQL logging or Hibernate statistics in a test and count the queries.

Fix: a fetch join or @EntityGraph for that use case, batch fetching, or a DTO projection.

Careful: fetch-joining a collection while paging makes Hibernate page in memory.

Sample spoken answer:

"N+1 happens when I load a list of, say, 50 orders with one query, then loop over them and call getItems on each. Because items is lazy, Hibernate runs a separate query per order, so I get one query plus 50 more. It's fine in development with ten rows and falls over in production. I spot it by turning on SQL logging or Hibernate statistics in an integration test and checking the query count, or by seeing lots of identical queries in the database monitor. The fix depends on the use case. If this screen always needs the items, I add a repository method with a join fetch or an @EntityGraph so it's one query. If I only need a few columns, a DTO projection is even better. Batch fetching is a good general setting that turns N queries into a handful. I don't switch the mapping to eager, because then every other query pays for it."

Code:
public interface OrderRepository extends JpaRepository<Order, Long> {

    @EntityGraph(attributePaths = "items")
    List<Order> findByCustomerId(Long customerId);

    @Query("select distinct o from Order o join fetch o.items where o.status = :status")
    List<Order> findWithItemsByStatus(@Param("status") OrderStatus status);
}
Red flag to avoid:

Fixing it by making everything eager, or never having looked at the SQL Hibernate actually runs.

They may ask next:
  • Why is changing the association to FetchType.EAGER a poor fix?
  • What goes wrong when you combine a collection fetch join with pagination?
Say it in 60 seconds
Hard Technical round Mid-level, Senior Practice question

16. You get a LazyInitializationException when an entity is turned into JSON. Why does it happen, and what does open-in-view have to do with it?

What the interviewer is really testing:
Whether you understand where the persistence context ends and the trade-off behind Boot's open-in-view default, instead of just leaning on it.
Answer frame:

Cause: a lazy association is touched after the transaction and its persistence context have closed.

Open-in-view: Boot keeps the persistence context open for the whole web request by default, which hides the error.

The cost: lazy queries then run outside the transaction during rendering and can hold a connection longer.

Better fix: load what the response needs in the service and return DTOs; consider turning open-in-view off.

Sample spoken answer:

"Lazy associations are proxies that load when first touched, but they need an open persistence context to do it. If my service returns an entity, the transaction ends, and then Jackson touches a lazy collection while writing the JSON, there's no session left, so Hibernate throws LazyInitializationException. Boot enables open-in-view by default, which keeps the persistence context open until the web request finishes, and it logs a warning about that at startup. That makes the exception go away, but now lazy queries run outside any transaction while the response is being written. They're easy to miss, they can create N+1 problems, and the database connection can stay held for the rest of the request. I prefer turning open-in-view off, deciding in the service what each endpoint needs, fetching it with an entity graph or a query, and mapping to a DTO before the transaction ends."

Red flag to avoid:

Fixing it with FetchType.EAGER everywhere, or putting @Transactional on the controller without understanding the cost.

They may ask next:
  • Beyond this exception, why is returning JPA entities straight from controllers risky?
  • What would you check before switching open-in-view off in a large existing app?
Say it in 60 seconds
Hard Technical round Mid-level, Senior Practice question

17. You put @Transactional on a method, but changes still aren't rolled back when it fails. What are the usual reasons?

What the interviewer is really testing:
Whether you know @Transactional works through a proxy and the rules that follow from that, which sit behind most real transaction bugs.
Answer frame:

Proxy: the annotation only applies when the call comes in through the Spring proxy, so self-calls skip it.

Beans only: it applies to Spring-managed beans; objects made with new get nothing, and private methods are never intercepted.

Rollback rules: by default only unchecked exceptions and errors roll back; checked exceptions commit.

Swallowed errors: catching the exception inside the method means the proxy never sees it.

Sample spoken answer:

"@Transactional works through a proxy. Spring wraps my bean, and the proxy starts the transaction before calling my method and commits or rolls back afterwards. So the first thing I check is whether the call actually went through the proxy. If one method in a class calls another annotated method in the same class, that's a call on this, and no transaction logic runs. Same if the object was created with new rather than injected. Second, the default rollback rule: runtime exceptions and errors roll back, but checked exceptions commit unless I set rollbackFor. Third, if the method catches the exception and just logs it, the proxy sees a normal return and commits. Private methods are never intercepted either. With more than one data source, I'd check it's using the right transaction manager. For self-calls, the usual fix is moving the method into a separate bean."

Code:
@Service
public class InvoiceService {

    public void importAll(List<Invoice> invoices) {
        invoices.forEach(this::saveOne); // self-call: the proxy is bypassed, no transaction
    }

    @Transactional
    public void saveOne(Invoice invoice) {
        // ...
    }
}
Red flag to avoid:

Assuming @Transactional works however the method is called, or that every exception causes a rollback.

They may ask next:
  • How would you prove in a test that a rollback really happened?
  • What does readOnly = true actually change?
Say it in 60 seconds
Medium Technical round Mid-level, Senior Practice question

18. What's the difference between REQUIRED and REQUIRES_NEW propagation? Give me a case where REQUIRES_NEW is the right choice.

What the interviewer is really testing:
Whether you understand how nested transactional calls behave, and the hidden cost of starting a new transaction.
Answer frame:

REQUIRED: the default; join the current transaction or start one if there's none.

REQUIRES_NEW: suspend the current one and run in a separate transaction that commits on its own.

Use case: an audit or failure record that must be saved even if the main work rolls back.

Cost: it holds a second connection, which can exhaust the pool under load.

Sample spoken answer:

"REQUIRED is the default. If there's already a transaction, the method joins it; if not, it starts one. So when one service calls another, both usually share one transaction and commit or roll back together. One detail people miss: if the inner method throws a runtime exception and the outer method catches it, the shared transaction is already marked rollback-only, so the outer commit fails with UnexpectedRollbackException. REQUIRES_NEW suspends the outer transaction and runs the method in a brand new one that commits or rolls back by itself. I use it for things like an audit entry or a failed-payment record that must survive even when the main operation rolls back. The catch is that it needs a second database connection while the first is suspended. Under load with a small pool, every request can end up holding one connection and waiting for another, and everything stalls."

Red flag to avoid:

Thinking that catching an exception from an inner REQUIRED method lets the outer transaction commit normally.

They may ask next:
  • If the outer transaction rolls back after the REQUIRES_NEW method has committed, what happens to the inner work?
  • How is NESTED different from REQUIRES_NEW?
Say it in 60 seconds
Easy Technical round Fresher, Mid-level Practice question

19. How does Spring Data JPA turn a method like findByEmailAndActiveTrue into SQL, and when do you write the query yourself?

What the interviewer is really testing:
Whether you know what repository interfaces give you for free, where their limits are, and how paging works.
Answer frame:

Derived queries: the method name is parsed into a query when the app starts, so a typo fails fast.

Paging: a Pageable parameter adds sorting, limit and offset; a Page result also runs a count query.

Own query: use @Query or a projection when the name gets long or the query needs joins.

Sample spoken answer:

"Spring Data creates the implementation of my repository interface when the app starts. For findByEmailAndActiveTrue it parses the name: find by the email property, and active equals true, and builds a JPQL query from that. Because this happens at startup, a misspelt property name fails straight away rather than in production. If I add a Pageable parameter, it adds sorting, limit and offset, and if the return type is Page it also runs a count query to get the total. Slice skips that count, which is cheaper when I only need to know if there's a next page. Derived names are great for simple lookups, but once a name goes past three or four conditions, or I need joins, aggregates or a DTO projection, I write @Query with JPQL, or native SQL when I truly need database-specific features."

Code:
public interface UserRepository extends JpaRepository<User, Long> {

    Optional<User> findByEmailAndActiveTrue(String email);

    Page<User> findByRole(Role role, Pageable pageable);

    @Query("select new com.shop.UserSummary(u.id, u.name) from User u where u.createdAt > :since")
    List<UserSummary> recentSummaries(@Param("since") Instant since);
}
Red flag to avoid:

Writing enormous method names instead of a query, or not knowing that a Page result runs an extra count query.

They may ask next:
  • Why can a Page query get slow on a big table, and what would you use instead?
  • What does @Modifying do, and what else do you need with it?
Say it in 60 seconds
Hard Situational round Mid-level, Senior Practice question

20. A teammate's @Transactional method saves an order, calls an external payment API, then updates the order status. What would you raise in review?

What the interviewer is really testing:
Whether you see that a database transaction can't cover an external call, and know safer patterns for mixing the two.
Answer frame:

Connection held: the transaction keeps a database connection busy while waiting on the network.

No real rollback: if the status update fails, the payment has already happened and won't be undone.

Better shape: short transactions around each step, an idempotency key and a pending state.

Reliable events: an outbox table if other systems need to hear about it.

Sample spoken answer:

"I'd raise two problems. First, the transaction holds a database connection for the whole payment call. If the provider is slow, every checkout holds a connection while it waits, and under load the pool runs dry and unrelated endpoints start failing. Second, the rollback is an illusion. If the payment succeeds and the status update then throws, the database rolls back the order, but the customer has been charged and we have no record. I'd suggest splitting it. One short transaction saves the order as pending. The payment call happens outside any transaction, with an idempotency key so a retry can't charge twice. A second short transaction marks it paid or failed. A scheduled job picks up anything stuck in pending and checks with the provider. If other services need to know, I'd write an outbox row in the same transaction as the status change. And I'd explain it with the failure example, not just quote a rule."

Red flag to avoid:

Saying @Transactional will roll back the payment too, or only suggesting a longer timeout.

They may ask next:
  • How would the idempotency key actually work with the payment provider?
  • What should the scheduled job do with an order stuck in pending?
Say it in 60 seconds
Medium Situational round Mid-level, Senior Practice question

21. A developer wants to keep spring.jpa.hibernate.ddl-auto set to update in production because it saves writing migrations. How do you respond?

What the interviewer is really testing:
Whether you know how schema changes should reach a production database safely, and can persuade rather than just forbid.
Answer frame:

Risk: update won't rename or drop safely, can't migrate data, and runs unreviewed at startup.

Alternative: versioned migrations with Flyway or Liquibase, kept in the repo and reviewed like code.

Setting: validate or none in production, so Hibernate never changes the schema itself.

Persuade: show a concrete failure and make the new path easy.

Sample spoken answer:

"I get why it's tempting, it feels free. But update only adds things. It won't rename a column, it can't move data from an old column into a new one, and it doesn't drop what's no longer used, so the schema slowly drifts. Worse, the change happens silently when the app starts, nobody reviews the SQL, and there's no record of what ran on which environment. I'd suggest Flyway or Liquibase instead: each change is a versioned script in the repo, reviewed like code and applied the same way everywhere. Boot runs them automatically at startup when the library is on the classpath. In production I'd set ddl-auto to validate or none, so Hibernate can check the mapping but never alters the schema. To win the argument, I'd walk through a real column rename and show where update breaks, then set up the first migration myself so the new way costs them nothing."

Red flag to avoid:

Agreeing because it works fine in development, or banning it without offering a workable migration process.

They may ask next:
  • How do you rename a column without downtime when old and new app versions run side by side?
  • Would you run migrations at app startup or as a separate pipeline step? Why?
Say it in 60 seconds

Security 3 questions

Medium Technical round Mid-level Practice question

22. How does Spring Security fit into a Spring Boot app, and how do you configure which endpoints are public and which need a login?

What the interviewer is really testing:
Whether you know Security works as a servlet filter chain and can write the current SecurityFilterChain style of configuration.
Answer frame:

Default: adding the starter locks down every endpoint with a generated user and password.

Filters: a chain of security filters runs before the DispatcherServlet and fills the SecurityContext.

Config: declare a SecurityFilterChain bean; the old WebSecurityConfigurerAdapter is gone.

Rules: list specific matchers first and anyRequest last.

Sample spoken answer:

"Spring Security plugs in as a servlet filter, so it runs before the DispatcherServlet. Inside that one filter is a chain of security filters that read credentials, build the Authentication, store it in the SecurityContext and finally check whether the request is allowed. As soon as I add the starter, Boot secures every endpoint and logs a generated password for a default user, which is a safe default but not what I want. So I declare a SecurityFilterChain bean. With authorizeHttpRequests I say which paths are public, like the health check, which need a role, and then anyRequest().authenticated() last, because rules are checked in order. The older approach of extending WebSecurityConfigurerAdapter has been removed, so on a current project it's always the bean style. For stored passwords I keep only hashes, using a PasswordEncoder like BCrypt."

Code:
@Configuration
@EnableWebSecurity
public class SecurityConfig {

    @Bean
    SecurityFilterChain api(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests(auth -> auth
                .requestMatchers("/actuator/health", "/public/**").permitAll()
                .requestMatchers("/admin/**").hasRole("ADMIN")
                .anyRequest().authenticated())
            .httpBasic(Customizer.withDefaults());
        return http.build();
    }

    @Bean
    PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}
Red flag to avoid:

Putting anyRequest() before the specific rules, or storing passwords in plain text or with a fast hash.

They may ask next:
  • What's the difference between hasRole and hasAuthority?
  • How would you protect a single service method rather than a URL?
Say it in 60 seconds
Hard Technical round Mid-level, Senior Practice question

23. For a stateless REST API that uses JWT bearer tokens, how would you set up Spring Security? Is it safe to turn CSRF protection off?

What the interviewer is really testing:
Whether you understand why CSRF protection exists, so you switch it off for the right reason rather than because a tutorial did.
Answer frame:

Resource server: use the OAuth2 resource server support to validate JWTs against the issuer's keys.

Stateless: set the session policy to stateless so no server session is created.

CSRF logic: the attack abuses credentials the browser sends automatically, like cookies.

Verdict: a token in the Authorization header isn't sent automatically, so CSRF can go; a token in a cookie keeps it.

Sample spoken answer:

"I'd use Spring Security's OAuth2 resource server support with JWT, point it at the identity provider's issuer, and let it fetch the public keys and check the signature, expiry and issuer on every request. I set session creation to stateless so no HTTP session is created, and map claims like scopes or roles to authorities. On CSRF, it depends on how the token travels. A CSRF attack works because the browser attaches cookies to a request that another site triggers. If my client sends the JWT in the Authorization header, the browser never adds it on its own, so a forged request arrives without credentials, and disabling CSRF is reasonable. But if the token lives in a cookie, the browser does send it automatically, and I'm back in CSRF territory, so I keep protection on. And I wouldn't hand-roll JWT parsing in a filter when the built-in support covers it."

Code:
@Bean
SecurityFilterChain api(HttpSecurity http) throws Exception {
    http
        .csrf(csrf -> csrf.disable()) // only because tokens travel in the Authorization header
        .sessionManagement(s -> s.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
        .authorizeHttpRequests(auth -> auth.anyRequest().authenticated())
        .oauth2ResourceServer(oauth -> oauth.jwt(Customizer.withDefaults()));
    return http.build();
}
Red flag to avoid:

Disabling CSRF out of habit without knowing what it protects against, or parsing JWTs by hand without verifying the signature.

They may ask next:
  • How do you cut off a user whose JWT hasn't expired yet?
  • Where would you keep tokens in a browser app, and what are the trade-offs?
Say it in 60 seconds
Medium Situational round Mid-level, Senior Practice question

24. You notice production exposes every Actuator endpoint to the internet with no login. What do you do, and in what order?

What the interviewer is really testing:
Whether you recognise the real risk, such as secrets in env and heap dumps, and act quickly and in proportion.
Answer frame:

Contain: cut exposure right away, at the gateway or through config.

Assess: check access logs for hits on env, configprops or heapdump, and treat exposed secrets as leaked.

Fix for good: expose only health and metrics, use a separate management port or auth, and add a pipeline check.

Sample spoken answer:

"I'd treat it as a security incident, not a tidy-up. The first step is to cut exposure, either by blocking /actuator at the load balancer or gateway, which is fastest, or by shipping a config change that limits exposure to health. Then I'd check the access logs for requests to env, configprops, heapdump or threaddump. A heap dump can hold passwords, tokens and customer data from memory, and although recent versions mask values in env by default, I wouldn't bet on that. If anything sensitive was hit, or I can't tell, I'd rotate the database password, API keys and signing keys. Then the lasting fix: a separate management port reachable only internally or behind authentication, an explicit list of exposed endpoints, and a pipeline check that fails the build if exposure is set to everything. And I'd tell the security team early, not after I've fixed it."

Red flag to avoid:

Quietly changing the config without checking what was accessed or rotating secrets that may have leaked.

They may ask next:
  • Why is heapdump more dangerous than it looks?
  • How would you still let your monitoring system scrape metrics safely?
Say it in 60 seconds

Testing & Ops 3 questions

Easy Technical round Fresher, Mid-level Practice question

25. What does Spring Boot Actuator give you, and which of its endpoints would you expose in production?

What the interviewer is really testing:
Whether you use Actuator for real operations, meaning health, metrics and probes, and know the security side of exposing it.
Answer frame:

Endpoints: health, info, metrics, loggers, env, beans, conditions and more.

Default: over HTTP only health is exposed; everything else is opt-in.

Probes: liveness and readiness health groups for orchestrators.

Metrics: Micrometer exports to a monitoring system such as Prometheus.

Sample spoken answer:

"Actuator adds operational endpoints under /actuator. Health tells a load balancer or orchestrator whether the app and things like its database are fine. Metrics, through Micrometer, gives request timings, JVM memory, connection pool usage and my own counters, and can export them to a monitoring system. Loggers lets me change a log level at runtime, and there are diagnostic ones like env, beans, conditions and heapdump. By default only health is exposed over HTTP. In production I'd expose health, info and the metrics or Prometheus endpoint, and I'd use the liveness and readiness groups so the platform only restarts the app when it's truly stuck, and stops sending traffic while it isn't ready. Anything sensitive, like env or heapdump, stays off or sits on a separate management port that only the internal network can reach, behind authentication."

Red flag to avoid:

Exposing every endpoint publicly, or putting a flaky downstream dependency into the liveness check so the app restarts in a loop.

They may ask next:
  • What should a liveness check include, and what should it leave out?
  • How would you add a custom health indicator for a downstream service?
Say it in 60 seconds
Medium Technical round Mid-level Practice question

26. When do you use @SpringBootTest versus @WebMvcTest or @DataJpaTest? And how do you swap a bean for a mock in a Spring test?

What the interviewer is really testing:
Whether you keep a test suite fast by loading only what each test needs, and know how to replace a bean in the context.
Answer frame:

Unit first: most logic is tested with plain JUnit and Mockito, no Spring at all.

Slices: @WebMvcTest loads the web layer with MockMvc; @DataJpaTest loads JPA and the repositories.

Full context: @SpringBootTest for a few end-to-end paths, ideally against a real database in a container.

Mocking: @MockitoBean replaces a bean in the context; older versions use @MockBean.

Sample spoken answer:

"I think in layers. Business logic gets plain unit tests with Mockito and no Spring, so they run in milliseconds. For a controller I use @WebMvcTest, which loads only the web layer: controllers, advice, converters and MVC config, but not services or repositories. I mock the service and use MockMvc to check status codes, JSON and validation errors. For repositories I use @DataJpaTest, which sets up JPA and rolls back each test's transaction. I prefer pointing it at a real database in a container rather than an in-memory one, because dialect differences hide bugs. @SpringBootTest loads everything, so I keep it for a handful of full-flow tests. To put a mock into the context, newer versions use @MockitoBean and older ones @MockBean. Each different set of mocks means a new context, so I keep them consistent to let Spring cache it."

Code:
@WebMvcTest(CustomerController.class)
class CustomerControllerTest {

    @Autowired MockMvc mvc;
    @MockitoBean CustomerService service; // @MockBean on older Boot versions

    @Test
    void returns404WhenCustomerIsMissing() throws Exception {
        when(service.find(42L)).thenThrow(new CustomerNotFoundException(42L));

        mvc.perform(get("/customers/42"))
           .andExpect(status().isNotFound());
    }
}
Red flag to avoid:

Using @SpringBootTest for every test, or relying only on an in-memory database that behaves differently from production.

They may ask next:
  • Why can a suite with many @SpringBootTest classes get slow, and how do you fix it?
  • How would you test that an endpoint is forbidden for a user without the right role?
Say it in 60 seconds
Hard Technical round Senior Practice question

27. A Spring Boot service is fine until traffic rises, then latency shoots up. Which pools and settings do you look at, and what do virtual threads change?

What the interviewer is really testing:
Whether you reason about request threads, database connections and blocking calls as one system, and measure before tuning.
Answer frame:

Measure: Actuator metrics for busy threads, pending connections and slow calls before changing anything.

Pools: server worker threads and the HikariCP connection pool must fit each other and the database.

Blocking calls: outbound HTTP calls need timeouts, or one slow dependency ties up every thread.

Virtual threads: make waiting cheap, but don't add database connections.

Sample spoken answer:

"I'd measure first. Actuator with Micrometer shows Hikari's active and pending connections, the server's busy threads and timings per endpoint. A common story is that Tomcat has far more worker threads than the connection pool has connections, so under load most threads sit waiting for a connection. Making the pool huge isn't the answer, because the database has its own limits and gets slower with too many concurrent queries. Instead I cut how long each request holds a connection: faster queries, no remote calls inside transactions. I also check every outbound HTTP client has connect and read timeouts, because one slow dependency can tie up every thread. On a recent Boot version with Java 21, turning on virtual threads makes a blocked thread nearly free, which helps with lots of slow I/O. But it doesn't create database connections, so the pool can become the bottleneck even faster."

Red flag to avoid:

Raising every pool size at once without measuring, or thinking virtual threads remove the database connection limit.

They may ask next:
  • How would you size the connection pool, and what would you watch after changing it?
  • When would you pick WebFlux over virtual threads?
Say it in 60 seconds

Real Work 3 questions

Medium Behavioral round Mid-level, Senior Practice question

28. Tell me about a production problem in a Spring Boot service that came from configuration or bean wiring rather than business logic.

What the interviewer is really testing:
Whether you can debug the framework layer calmly, find the real cause, and add a guard so the same class of mistake can't slip through again.
Answer frame:

Situation: what broke and how you noticed, briefly.

Trace: how you checked the active profile, properties or beans instead of guessing.

Fix: the quick fix, then the lasting guard, like a startup check or a test.

Sample spoken answer:

"At my last company, after a release, one service started sending real emails from staging. Nothing in the email code had changed. I checked the Actuator env endpoint on staging, which we kept on an internal port, and saw no active profile at all. A deployment change had renamed an environment variable, so SPRING_PROFILES_ACTIVE was never set. Our fake email sender was only registered under the staging profile, so with no profile the real sender was wired in instead. We paused the email job, restored the variable and redeployed within the hour. Then I fixed the root cause: the real sender now needs an explicit prod profile instead of being the fallback, and I added a startup check that fails if no profile is active. Since then a missing profile stops the app instead of quietly changing its behaviour."

Red flag to avoid:

Blaming the ops team without saying what you changed in the app, or a story that ends with no lasting guard against a repeat.

They may ask next:
  • How did you make sure no other beans behaved differently under the default profile?
  • What would you log at startup to make this kind of problem obvious?
Say it in 60 seconds
Hard Behavioral round Mid-level, Senior Practice question

29. Have you upgraded a service to a new major version of Spring Boot? What broke, and how did you keep the risk low?

What the interviewer is really testing:
Whether you can plan a framework upgrade in safe steps and know the kinds of breakage a major Boot version brings.
Answer frame:

Prepare: move to the latest minor of the old line first and clear deprecation warnings.

Known breaks: namespace or Java baseline changes, security config, Hibernate behaviour, renamed properties.

Tools: the properties migrator and solid integration tests.

Rollout: one service first, compare metrics, then the rest.

Sample spoken answer:

"I led the move of a few services from Boot 2 to Boot 3. First we upgraded to the last 2.x release and fixed every deprecation warning, because that's where the framework tells you what's going away. Then the big jump. The Java baseline moved to 17, and every javax import became jakarta, which was mostly search and replace but also meant upgrading two libraries that weren't ready. Security config had to move from the old adapter class to SecurityFilterChain beans. Hibernate 6 changed some query behaviour, and one native query started returning a different type, which only our integration tests caught. We added the properties migrator for one release so it logged renamed properties, then removed it. We shipped one low-traffic service first, watched error rates and latency for a week, and did the rest with a checklist from that first one."

Red flag to avoid:

Jumping straight to the new major version without clearing deprecations or having integration tests to catch behaviour changes.

They may ask next:
  • What would you do about a library that doesn't support the new version yet?
  • How did you get the team to spend time on an upgrade that adds no features?
Say it in 60 seconds
Medium Behavioral round Mid-level, Senior Practice question

30. Tell me about a slow endpoint in a Spring Boot app that you made faster. How did you find where the time was going?

What the interviewer is really testing:
Whether you measure before changing things and can trace time through the web, service and database layers of a Spring app.
Answer frame:

Measure: request timings from metrics or tracing, then narrow down to the slow part.

Cause: often queries, like N+1 or a missing index, or a blocking remote call.

Fix and prove: change one thing and compare before and after numbers.

Sample spoken answer:

"In my last project, the order history endpoint had become slow for customers with long histories, sometimes several seconds. Actuator metrics showed it as our slowest route, and a trace showed nearly all the time was in the database, spread over hundreds of tiny queries. Turning on SQL logging locally with realistic data made it obvious: we loaded the orders, then each order's items and each item's product lazily, a classic N+1 on two levels. I wrote a repository method with an entity graph for items and products, and changed the endpoint to return a paged DTO instead of the full list. I also added a test that counts queries, so it can't quietly come back. For the worst accounts it went from seconds to well under a quarter of a second, and database load dropped noticeably too."

Red flag to avoid:

Adding a cache first without knowing where the time goes, or claiming a speed-up with no before-and-after numbers.

They may ask next:
  • Why didn't the problem show up in testing?
  • What would you have done if the time was in a remote API instead of the database?
Say it in 60 seconds
Were you asked something else? Share it A person checks every question before it goes on the site. No name is shown.
For the call itself

The questions above are the prep. The call has ten more.

ClapAssist is an AI interview assistant for Mac and Windows. It listens to the interview on your computer and shows you what to say, in short lines you can read while you talk. Your resume and notes are never stored on our servers. It stays out of screen share on every plan; only you can see it.

Download ClapAssist with 10 free minutes
Mac and Windows · Stays out of screen share · No card