How to Answer Spring Boot Questions in Indian Interviews

How to answer the 7 Spring Boot questions Indian recruiters actually ask — auto-configuration, annotations, N+1 selects, transactions, JWT auth, with project examples.

PrepFox Team·

How to Answer Spring Boot Questions in Indian Interviews

Spring Boot is the backbone of Indian enterprise hiring. GeeksforGeeks lists it among the most-asked interview topics for Java roles in India, and recruiters at TCS, Infosys, and product startups probe candidates on exactly this gap: knowing annotations without understanding the "why."

Here is how to answer the Spring Boot questions Indian recruiters actually ask, with the depth that converts a screening round into an offer. For the broader role-by-role question bank, see PrepFox's complete interview question list.

1. "What is Spring Boot and why use it over Spring Framework?"

This is almost always the opener. The wrong answer lists features. The right answer shows you understand the problem Spring Boot solves.

How to answer: Spring Boot is an opinionated layer on top of Spring that removes manual configuration. Plain Spring requires XML or Java config for every bean, manual dependency versions, and WAR deployment to external Tomcat. Spring Boot gives you auto-configuration (beans set up based on classpath), starter dependencies (one POM entry pulls compatible versions of a whole stack), and an embedded server (the JAR runs itself). The result: a working REST API in five minutes.

2. "Explain @SpringBootApplication — what does it actually do?"

This tests whether you've read past the surface. The one-line answer: it combines three annotations.

How to answer: @SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan. @Configuration marks the class as a bean source. @EnableAutoConfiguration triggers Spring Boot's auto-config engine, which reads META-INF/spring.factories from your dependency JARs and applies @ConditionalOn… classes that match your classpath. @ComponentScan tells Spring to scan the package of the main class and below for @Component, @Service, @Repository, and @Controller beans.

Add depth: "Adding spring-boot-starter-data-jpa with H2 on the classpath auto-configures a DataSource, EntityManagerFactory, and JpaTransactionManager — no XML. I can disable specific ones with @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})." The official Spring Boot auto-configuration reference documents the full @ConditionalOn… family.

3. "Difference between @Component, @Service, @Repository, and @Controller?"

Interviewers ask this to check if you understand layering. All four are stereotype annotations built on @Component, but each signals a different role.

How to answer: @Component is the generic stereotype. @Service marks business-logic classes. @Repository marks persistence classes and adds automatic exception translation — it converts SQLException and JPA exceptions into Spring's DataAccessException hierarchy so your service layer doesn't depend on vendor-specific exceptions. @Controller / @RestController marks web handlers; @RestController adds @ResponseBody so methods return JSON instead of view names.

Practical point: "Spring Data JPA interfaces are @Repository by default. A @Service class shows up in stack traces as a service-layer call, which helps debugging."

4. "How does auto-configuration decide what to configure?"

This separates candidates who memorized annotations from those who understand the engine. The answer hinges on @Conditional annotations.

How to answer: Spring Boot loads AutoConfiguration classes from spring.factories. Each has conditions: @ConditionalOnClass activates only if a class is on the classpath; @ConditionalOnMissingBean only if no such bean exists; @ConditionalOnProperty checks an application.properties flag. Adding spring-boot-starter-web activates TomcatServletWebServerFactory because Tomcat classes are present. Exclude Tomcat and add Jetty — Jetty takes over.

5. "Explain the N+1 selects problem and how you fix it"

This is the most common JPA question at Indian product companies. A weak answer loses the round.

How to answer: N+1 happens when you fetch N parents with one query, then lazily load a child collection for each — firing N more queries. For 100 orders with 10 items each, you run 1 + 100 = 101 queries instead of one join.

Three fixes: (1) JOIN FETCH in JPQL pulls parents and children in one query. (2) @EntityGraph on the repository method for eager-fetch at query time without changing entity mappings. (3) @BatchSize batches lazy collection loads, cutting 100 queries to ~4. I use JOIN FETCH for known access patterns and @EntityGraph when the method is called with and without children.

6. "What are @Transactional propagation levels?"

Interviewers probe this to see if you've debugged real transaction issues, not just memorized the enum.

How to answer: REQUIRED (default) joins an existing transaction or creates one. REQUIRES_NEW suspends the current one and starts fresh — useful for audit logs that must persist even if the main flow rolls back. NESTED creates a savepoint. MANDATORY throws if no transaction exists. SUPPORTS runs in the caller's transaction if one exists, else non-transactionally. NOT_SUPPORTED and NEVER suspend or forbid transactions.

Pitfall freshers miss: "@Transactional only works through a Spring proxy. A direct call from another method in the same class bypasses the proxy and the transaction is silently ignored — the most common cause of partial commits I've debugged."

7. "How do you implement JWT authentication in Spring Boot?"

Security questions are standard at mid-to-senior interviews. A structured answer wins over a code dump.

How to answer: Three steps. (1) A /login endpoint verifies credentials via AuthenticationManager and returns a signed JWT with username, roles, and expiry. (2) A custom OncePerRequestFilter extracts the Bearer token, validates the signature, and loads the user into SecurityContextHolder. (3) SecurityFilterChain registers the filter before UsernamePasswordAuthenticationFilter and authorizes endpoints by role. Store the signing key in environment variables in production.

How Indian recruiters structure the round

A typical Spring Boot interview at an Indian company runs 45–60 minutes in a predictable arc. The first 10 minutes cover core Spring and Boot fundamentals (questions 1–3). The next 20 dive into data access (JPA, transactions, N+1). The last 15 cover a design or security scenario — JWT auth, a Resilience4j circuit breaker, or idempotency for a payment API. The strongest candidates connect each answer to a shipped project, naming the specific trade-off they made.

Salary reality and what to negotiate

Per ScholarHat's 2025 India salary guide, freshers start at ₹3.5–5 lakh, mid-level (3–5 years) earn ₹8–12 lakh, and seniors reach ₹15–25 lakh — higher in Bangalore, Pune, and Hyderabad. Product companies pay 30–50% above services firms. When negotiating, cite the Spring Boot modules you've shipped in production (security, data JPA, microservices, Actuator) rather than years alone. See PrepFox's Java interview guide for the core-language questions that pair with these.

Preparation checklist

  • Build one CRUD API with Spring Data JPA, one @Transactional service, and JWT auth.
  • Write out answers to all seven questions above in your own words; do not memorize scripts.
  • For each answer, prepare one project example with the specific trade-off you made.
  • Run a mock interview to test delivery — PrepFox's mock interview tool gives feedback on pacing.
  • Revise the latest Spring Boot version features the night before (virtual threads, structured logging, Docker Compose support).

The candidates who clear Spring Boot interviews in India are not the ones who know the most annotations — they are the ones who can explain why each annotation exists, debug the common pitfalls, and connect theory to a real project. Master the seven questions above, ship one end-to-end API, and walk in with a project example for each answer. That combination is what turns a screening round into an offer.

Ready to put this into practice?

Practice mock interviews, build your resume, and get expert feedback — all on PrepFox.