Core Spring Boot Test 2

    Question 1CORE SPRING BOOT - Default Configuration File

    What is the default location of application.properties or application.yml in a Spring Boot project?

    Question 2CORE SPRING BOOT - Starter Dependencies

    What is the main purpose of Spring Boot "starter dependencies"?

    Question 3CORE SPRING BOOT - @Bean Annotation

    What is the role of the @Bean annotation in Spring Boot?

    Question 4CORE SPRING BOOT - Code Snippet (@GetMapping)

    What URL will return "Hello World" in the following code?

    @RestController @RequestMapping("/api") public class HelloController { @GetMapping("/hello") public String hello() { return "Hello World"; } }

    Question 5CORE SPRING BOOT - Setter Injection

    Which of the following best describes setter-based dependency injection?

    Question 6CORE SPRING BOOT - Activating Profiles

    How can you activate a Spring profile in a Spring Boot application?

    Question 7CORE SPRING BOOT - Default Actuator Endpoints

    Which of the following is a default Spring Boot Actuator endpoint?

    Question 8CORE SPRING BOOT - Code Snippet (Global Exception Handler)

    What will happen when a NullPointerException is thrown in any controller in this code?

    @ControllerAdvice public class GlobalExceptionHandler { @ExceptionHandler(NullPointerException.class) public ResponseEntity<String> handleNull(Exception ex) { return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Null value found!"); } }

    Question 9CORE SPRING BOOT - Logging Levels

    Which of the following is not a standard logging level in SLF4J/Logback?

    Question 10CORE SPRING BOOT - Switching Embedded Servers

    How can you switch the embedded server from Tomcat to Jetty or Undertow?

    Question 11CORE SPRING BOOT - Profile-Specific Configuration

    How can you define configuration specific to a Spring profile in properties or YAML?

    Question 12CORE SPRING BOOT - Excluding Auto-Configuration

    If you want to exclude a specific auto-configuration class from being applied, how can you do that?

    Question 13CORE SPRING BOOT - Code Snippet (@Autowired)

    What will happen when the following code executes?

    @Component public class ServiceA { } @Component public class ServiceB { @Autowired private ServiceA serviceA; }

    Question 14CORE SPRING BOOT - Code Snippet (PathVariable)

    What will be returned if you access `/api/user/42` in the following code?

    @RestController @RequestMapping("/api") public class UserController { @GetMapping("/user/{id}") public String getUser(@PathVariable int id) { return "User ID: " + id; } }

    Question 15CORE SPRING BOOT - Field Injection

    What is a key drawback of field injection using @Autowired directly on fields?

    Question 16CORE SPRING BOOT - Profile-Specific YAML

    Which of the following is a correct way to define a profile-specific configuration in YAML?

    Question 17CORE SPRING BOOT - Health Endpoint Check

    Which of the following statements about the `/health` endpoint is correct?

    Question 18CORE SPRING BOOT - Local vs Global Exception Handling

    Which statement is correct regarding local vs global exception handling in Spring Boot?

    Question 19CORE SPRING BOOT - Code Snippet (SLF4J Logging)

    What will the following code output if the logging level is set to INFO?

    import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class LoggingExample { private static final Logger logger = LoggerFactory.getLogger(LoggingExample.class); public void run() { logger.debug("Debug message"); logger.info("Info message"); logger.error("Error message"); } }

    Question 20CORE SPRING BOOT - Embedded Server Ports

    Which property is used to configure the port of an embedded server in Spring Boot?