Spring Boot RestController & Request Mapping

    Question 1CORE SPRING BOOT - @RestController Purpose

    What is the primary purpose of the `@RestController` annotation in Spring Boot?

    Question 2CORE SPRING BOOT - @GetMapping vs @RequestMapping

    Which statement is correct regarding `@GetMapping` and `@RequestMapping`?

    Question 3CORE 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 4CORE 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 5CORE SPRING BOOT - Query Parameters with @RequestParam

    Which annotation is used to extract query parameters in a Spring Boot controller?

    Question 6CORE SPRING BOOT - Code Snippet (@RequestParam)

    What will `/api/user?id=10` return in the following code?

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

    Question 7CORE SPRING BOOT - Default Values with @RequestParam

    How can you set a default value for a query parameter?

    Question 8CORE SPRING BOOT - Code Snippet (@PostMapping)

    Which HTTP method does the following handler respond to?

    @RestController @RequestMapping("/api") public class ProductController { @PostMapping("/product") public String addProduct(@RequestBody String name) { return "Added product: " + name; } }

    Question 9CORE SPRING BOOT - Combining Path and Query Parameters

    How do you correctly handle both path and query parameters in Spring Boot?

    Question 10CORE SPRING BOOT - Best Practices for REST Endpoints

    Which of the following are considered best practices for REST controllers in Spring Boot?