Spring Boot Interview Questions Hindi mein

Spring Boot कोर्स के 25 सवाल, हर सवाल के सही जवाब और explanation के साथ। जवाब देखने से पहले ख़ुद सोचें।

Spring Boot Fundamentals

1. What does Spring Boot add on top of the Spring Framework?

  1. A database engine
  2. A new programming language
  3. Starters, auto-configuration, an embedded server and production features
  4. A replacement for Java
जवाब देखें

जवाब: Starters, auto-configuration, an embedded server and production features

Conventions and defaults on top of Spring.

पाठ: Spring and Spring Boot

2. Why do starters usually omit version numbers?

  1. The Spring Boot parent manages compatible versions
  2. Versions are optional in Maven always
  3. Starters have no versions
  4. Maven picks random versions
जवाब देखें

जवाब: The Spring Boot parent manages compatible versions

Dependency management keeps versions aligned.

पाठ: Starters and the Project Layout

3. What decides which auto-configurations apply?

  1. Only the main method arguments
  2. Alphabetical order
  3. A random choice
  4. Conditions such as classes on the classpath, existing beans and properties
जवाब देखें

जवाब: Conditions such as classes on the classpath, existing beans and properties

Conditional configuration.

पाठ: Auto-Configuration and the Main Class

Dependency Injection and Configuration

4. What is a Spring bean?

  1. A Java coffee class
  2. An object created and managed by the Spring container
  3. A database table
  4. A configuration file
जवाब देखें

जवाब: An object created and managed by the Spring container

The container owns bean lifecycles.

पाठ: Beans and the Application Context

5. Why is constructor injection preferred?

  1. It is the only way Spring works
  2. Dependencies are explicit, fields can be final, and tests can use new
  3. It makes startup slower on purpose
  4. It hides dependencies
जवाब देखें

जवाब: Dependencies are explicit, fields can be final, and tests can use new

Explicit and testable.

पाठ: Constructor Injection

6. What does @ConfigurationProperties(prefix = "shop") do?

  1. Defines a REST endpoint
  2. Creates a database table
  3. Disables configuration
  4. Binds shop.* settings to a typed class or record
जवाब देखें

जवाब: Binds shop.* settings to a typed class or record

Type-safe configuration.

पाठ: Typed Configuration Properties

Building REST APIs

7. Why return DTO records instead of JPA entities?

  1. The API stays stable and does not leak database structure
  2. Entities cannot be serialised
  3. Records are faster to query
  4. Spring forbids returning entities
जवाब देखें

जवाब: The API stays stable and does not leak database structure

Separate API and persistence models.

पाठ: REST Controllers

8. Which annotation reads ?max=1000 from the URL?

  1. @RequestBody
  2. @PathVariable
  3. @RequestParam
  4. @Entity
जवाब देखें

जवाब: @RequestParam

Query parameters map to @RequestParam.

पाठ: Request Mapping and Parameters

9. What triggers validation of a request body?

  1. Adding a database index
  2. Naming the class Valid
  3. The @Valid annotation on the parameter, with constraints on the DTO fields
  4. Returning ResponseEntity
जवाब देखें

जवाब: The @Valid annotation on the parameter, with constraints on the DTO fields

@Valid plus constraint annotations.

पाठ: Validating Input

10. What is RFC 9457?

  1. A standard JSON format for HTTP API problem details
  2. A Java version
  3. A database isolation level
  4. A logging library
जवाब देखें

जवाब: A standard JSON format for HTTP API problem details

Standard, parseable errors.

पाठ: Problem Details for Errors

Data Access With Spring Data JPA

11. Why does a JPA entity need a no-argument constructor?

  1. It is used for validation only
  2. Spring forbids other constructors
  3. It speeds up queries
  4. The JPA provider uses it to create instances when loading data
जवाब देखें

जवाब: The JPA provider uses it to create instances when loading data

It can be protected to discourage misuse.

पाठ: JPA Entities

12. How does Spring Data implement findByPriceLessThan?

  1. You must write the SQL in a separate class
  2. It derives the query from the method name
  3. It loads all rows and filters in Java always
  4. It calls an external API
जवाब देखें

जवाब: It derives the query from the method name

Naming conventions become queries.

पाठ: Repositories and Derived Queries

13. Where should @Transactional usually be placed?

  1. On JSON DTO records
  2. On service-layer methods that define a unit of work
  3. On the main method
  4. On every getter
जवाब देखें

जवाब: On service-layer methods that define a unit of work

Services own transaction boundaries.

पाठ: Transactions and Open Session in View

Testing Spring Boot Applications

14. What does @WebMvcTest start?

  1. Only the JPA layer
  2. The whole application including the database
  3. Nothing; it is a unit test without Spring
  4. Only the web layer, with MockMvc and mocked dependencies
जवाब देखें

जवाब: Only the web layer, with MockMvc and mocked dependencies

A focused slice.

पाठ: Web Layer Tests With @WebMvcTest

15. What happens to data written in a @DataJpaTest test by default?

  1. It is rolled back after each test
  2. It is committed permanently
  3. It is written to production
  4. It is exported to CSV
जवाब देखें

जवाब: It is rolled back after each test

Tests stay isolated.

पाठ: Repository Tests With @DataJpaTest

16. Why did moving the seeder out of the main class fix the slice tests?

  1. The main class cannot have methods
  2. Components run faster
  3. Slices load @Bean methods on the main class but filter out ordinary @Component classes
  4. CommandLineRunner is deprecated
जवाब देखें

जवाब: Slices load @Bean methods on the main class but filter out ordinary @Component classes

Keep the @SpringBootApplication class minimal.

पाठ: Pitfall: Beans Declared on the Main Class

Running and Operating Applications

17. What does the db component in /actuator/health check?

  1. User passwords
  2. Disk encryption
  3. That the application can reach its database
  4. Network bandwidth
जवाब देखें

जवाब: That the application can reach its database

Health aggregates dependency checks.

पाठ: Actuator Health and Metrics

18. Which overrides a value in application.properties inside the jar?

  1. An environment variable or command-line argument
  2. A comment in the code
  3. The jar file name
  4. Nothing can override it
जवाब देखें

जवाब: An environment variable or command-line argument

External configuration wins.

पाठ: Profiles and External Configuration

19. What does a Spring Boot executable jar contain?

  1. A database dump
  2. Only your source code
  3. Only configuration files
  4. The application plus its dependencies and an embedded server
जवाब देखें

जवाब: The application plus its dependencies and an embedded server

Self-contained deployment unit.

पाठ: Packaging and Running

Security and Observability

20. What happens when Spring Security is added with no configuration?

  1. Nothing changes
  2. All endpoints require authentication by default
  3. All endpoints become public
  4. The app fails to start
जवाब देखें

जवाब: All endpoints require authentication by default

Secure by default.

पाठ: Spring Security Basics

21. Which library does Spring Boot use for metrics instrumentation?

  1. JUnit
  2. Micrometer
  3. Hibernate
  4. Thymeleaf
जवाब देखें

जवाब: Micrometer

Vendor-neutral metrics.

पाठ: Metrics, Logs and Traces

22. What do virtual threads (Java 21+) help with?

  1. Removing the need for a database
  2. Reducing JSON size
  3. Encrypting data
  4. Handling many concurrent blocking requests with simple code
जवाब देखें

जवाब: Handling many concurrent blocking requests with simple code

Cheap threads for blocking I/O.

पाठ: Resilience and Performance

Structure, Upgrades and a Checklist

23. What does package-by-feature mean?

  1. Grouping each feature's controller, service and repository together
  2. One package per annotation type
  3. Putting all code in the main class
  4. A package per developer
जवाब देखें

जवाब: Grouping each feature's controller, service and repository together

Cohesive modules.

पाठ: Project Structure

24. What is a safe way to upgrade Spring Boot?

  1. Override every managed dependency version
  2. Skip several major versions without testing
  3. One version at a time, following the migration guide and running all tests
  4. Never upgrade
जवाब देखें

जवाब: One version at a time, following the migration guide and running all tests

Incremental, tested upgrades.

पाठ: Upgrading Spring Boot

25. Which item belongs on a Spring Boot review checklist?

  1. Expose all Actuator endpoints publicly
  2. Field injection everywhere
  3. spring.jpa.open-in-view is disabled and transactions live in services
  4. Return JPA entities directly from every endpoint
जवाब देखें

जवाब: spring.jpa.open-in-view is disabled and transactions live in services

Explicit boundaries and safe defaults.

पाठ: A Spring Boot Review Checklist

← कोर्स पर वापस जाएँ