Spring Boot MCQs

  1. Which of the following is true about Spring Boot?
    a) Simplifies Spring application development
    b) Provides auto configuration
    c) Includes embedded servers
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  2. What will be printed?
    1 import org.springframework.boot.*;
    2 import org.springframework.boot.autoconfigure.*;
    3 @SpringBootApplication
    4 public class EduinqApp {
    5 public static void main(String[] args) {
    6 SpringApplication.run(EduinqApp.class, args);
    7 System.out.println("Eduinq Boot Started");
    8 }
    9 }
    a) Eduinq Boot Started
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Eduinq Boot Started

  3. Which of the following is true about Spring Boot auto configuration?
    a) Provides sensible defaults
    b) Controlled via @EnableAutoConfiguration
    c) Can be excluded with @SpringBootApplication(exclude=...)
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  4. Which of the following is true about Spring Boot starters?
    a) Pre configured dependency descriptors
    b) Simplify Maven/Gradle setup
    c) Examples: spring boot starter web, spring boot starter data jpa
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  5. Which of the following is true about Spring Boot embedded servers?
    a) Includes Tomcat, Jetty, Undertow
    b) Run without external server setup
    c) Configurable via properties
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  6. Which of the following is true about @RestController annotation?
    a) Combines @Controller and @ResponseBody
    b) Simplifies REST API creation
    c) Returns JSON/XML directly
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  7. What will be printed?
    1 import org.springframework.web.bind.annotation.*;
    2 @RestController
    3 class EduinqController {
    4 @GetMapping("/hello")
    5 public String hello(){ return "Eduinq REST Hello"; }
    6 }
    a) Eduinq REST Hello
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Eduinq REST Hello

  8. Which of the following is true about @GetMapping annotation?
    a) Shortcut for @RequestMapping(method=GET)
    b) Maps HTTP GET requests
    c) Used in REST controllers
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  9. Which of the following is true about @PostMapping annotation?
    a) Shortcut for @RequestMapping(method=POST)
    b) Maps HTTP POST requests
    c) Used in REST controllers
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  10. Which of the following is true about Spring Boot application.properties?
    a) Configures application settings
    b) Supports key=value format
    c) Can override defaults
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  11. Which of the following is true about Spring Boot profiles?
    a) Allow environment specific configuration
    b) Activated via spring.profiles.active property
    c) Annotated with @Profile
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  12. What will be printed?
    1 import org.springframework.context.annotation.*;
    2 @Configuration
    3 @Profile("dev")
    4 class EduinqConfig {
    5 @Bean
    6 public String msg(){ return "Eduinq Dev Profile"; }
    7 }
    a) Eduinq Dev Profile (if dev active)
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Eduinq Dev Profile (if dev active)

  13. Which of the following is true about @Conditional annotation?
    a) Defines conditional bean creation
    b) Used with custom conditions
    c) Supports annotations like @ConditionalOnProperty
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  14. Which of the following is true about @ConditionalOnProperty?
    a) Creates bean if property matches
    b) Used in auto configuration classes
    c) Supports havingValue attribute
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  15. What will be printed?
    1 import org.springframework.boot.autoconfigure.condition.*;
    2 import org.springframework.context.annotation.*;
    3 @Configuration
    4 class EduinqConfig {
    5 @Bean
    6 @ConditionalOnProperty(name="eduinq.enabled", havingValue="true")
    7 public String msg(){ return "Eduinq Conditional Bean"; }
    8 }
    a) Eduinq Conditional Bean (if property set)
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Eduinq Conditional Bean (if property set)

  16. Which of the following is true about @ConditionalOnClass?
    a) Creates bean if class present
    b) Used in auto configuration
    c) Promotes modularity
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  17. Which of the following is true about @ConditionalOnMissingBean?
    a) Creates bean if not already defined
    b) Prevents duplicate beans
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  18. Which of the following is true about Spring Boot Actuator?
    a) Provides monitoring endpoints
    b) Includes /health, /info, /metrics
    c) Configurable via properties
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  19. Which of the following is true about @SpringBootTest annotation?
    a) Provides integration testing support
    b) Loads full application context
    c) Used with JUnit tests
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  20. Which of the following is true about Spring Boot DevTools?
    a) Provides automatic restart
    b) Enables live reload
    c) Improves developer productivity
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  21. Which of the following is true about @PathVariable in Spring Boot?
    a) Binds URI template variables to method parameters
    b) Used in REST controllers
    c) Supports type conversion
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  22. What will be printed?
    1 import org.springframework.web.bind.annotation.*;
    2 @RestController
    3 class EduinqController {
    4 @GetMapping("/eduinq/{name}")
    5 public String hello(@PathVariable String name){
    6 return "Eduinq " + name;
    7 }
    8 }
    a) Eduinq Portal (if /eduinq/Portal called)
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Eduinq Portal (if /eduinq/Portal called)

  23. Which of the following is true about @RequestBody annotation?
    a) Binds request JSON to method parameter
    b) Used in REST controllers
    c) Supports automatic deserialization
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  24. What will be printed?
    1 import org.springframework.web.bind.annotation.*;
    2 class Eduinq {
    3 public String name;
    4 }
    5 @RestController
    6 class EduinqController {
    7 @PostMapping("/eduinq")
    8 public String create(@RequestBody Eduinq e){
    9 return "Eduinq " + e.name;
    10 }
    11 }
    a) Eduinq Portal (if JSON {"name":"Portal"} sent)
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Eduinq Portal (if JSON {"name":"Portal"} sent)

  25. Which of the following is true about @ResponseEntity?
    a) Represents HTTP response with status, headers, body
    b) Provides flexibility in REST APIs
    c) Supports custom status codes
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  26. Which of the following is true about @ConfigurationProperties?
    a) Binds external properties to POJOs
    b) Supports hierarchical mapping
    c) Requires @EnableConfigurationProperties or @Component
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  27. What will be printed?
    1 import org.springframework.boot.context.properties.ConfigurationProperties;
    2 @ConfigurationProperties(prefix="eduinq")
    3 class EduinqProps {
    4 private String name;
    5 public String getName(){ return name; }
    6 public void setName(String name){ this.name=name; }
    7 }
    a) Value of eduinq.name from properties
    b) Eduinq
    c) Compilation error
    d) Runtime exception
    View Answer

    Correct answer: A — Value of eduinq.name from properties

  28. Which of the following is true about Spring Boot Actuator custom endpoints?
    a) Developers can define custom endpoints
    b) Annotated with @Endpoint
    c) Exposed via /actuator path
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  29. Which of the following is true about @ConditionalOnExpression?
    a) Creates bean if SpEL expression evaluates true
    b) Used in auto configuration classes
    c) Provides flexibility
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  30. Which of the following is true about Spring Boot logging?
    a) Uses Commons Logging internally
    b) Defaults to Logback
    c) Configurable via application.properties
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  31. Which of the following is true about Spring Boot externalized configuration?
    a) Supports properties, YAML, environment variables
    b) Command line arguments override defaults
    c) Promotes flexibility
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  32. Which of the following is true about @ConditionalOnResource?
    a) Creates bean if resource available
    b) Useful for file based conditions
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  33. Which of the following is true about Spring Boot banner?
    a) Displayed at startup
    b) Customizable via banner.txt
    c) Can be disabled via properties
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  34. Which of the following is true about @EnableConfigurationProperties?
    a) Enables support for @ConfigurationProperties beans
    b) Used in @Configuration classes
    c) Promotes modular configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  35. Which of the following is true about Spring Boot DevTools restart?
    a) Restarts app on classpath changes
    b) Improves developer productivity
    c) Can be disabled
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  36. Which of the following is true about @ConditionalOnWebApplication?
    a) Creates bean if web app context present
    b) Used in auto configuration
    c) Promotes modularity
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  37. Which of the following is true about @ConditionalOnNotWebApplication?
    a) Creates bean if not web app context
    b) Used in auto configuration
    c) Promotes modularity
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  38. Which of the following is true about Spring Boot testing slices?
    a) @WebMvcTest for controllers
    b) @DataJpaTest for JPA repositories
    c) @JsonTest for JSON serialization
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  39. Which of the following is true about Spring Boot @Import annotation?
    a) Imports configuration classes
    b) Promotes modularity
    c) Equivalent to XML import
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  40. Which of the following is true about @EnableAutoConfiguration exclusion?
    a) Excludes specific auto config classes
    b) Configured via exclude attribute
    c) Promotes customization
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  41. Which of the following is true about Spring Boot CLI?
    a) Allows running Groovy scripts
    b) Simplifies prototyping
    c) Supports auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  42. Which of the following is true about Spring Boot @ConditionalOnJava?
    a) Creates bean based on Java version
    b) Useful for compatibility checks
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  43. Which of the following is true about Spring Boot @ConditionalOnCloudPlatform?
    a) Creates bean if running on cloud platform
    b) Supports CloudFoundry, Heroku, etc.
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  44. Which of the following is true about Spring Boot @ConditionalOnSingleCandidate?
    a) Creates bean if only one candidate present
    b) Useful for autowiring
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  45. Which of the following is true about Spring Boot @ConditionalOnBean?
    a) Creates bean if another bean present
    b) Promotes modularity
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  46. Which of the following is true about Spring Boot @ConditionalOnMissingClass?
    a) Creates bean if class not present
    b) Useful for optional dependencies
    c) Used in auto configuration
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  47. Which of the following is true about Spring Boot @ConditionalOnProperty best practices?
    a) Use clear property names
    b) Provide defaults
    c) Avoid complex conditions
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  48. Which of the following is true about Spring Boot @Conditional annotations overall?
    a) Provide flexible bean creation
    b) Promote modular auto configuration
    c) Improve maintainability
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  49. Which of the following is true about Spring Boot best practices?
    a) Use profiles for environments
    b) Externalize configuration
    c) Keep controllers thin, services rich
    d) All of the above
    View Answer

    Correct answer: D — All of the above

  50. Which of the following is true about Spring Boot REST API best practices?
    a) Use proper HTTP methods
    b) Return meaningful status codes
    c) Externalize configuration and avoid hardcoding
    d) All of the above
    View Answer

    Correct answer: D — All of the above

Quick Links to Explore