QuizzesRequest Mapping & HTTP Methods — Concept Check
intermediate
spring-boot

Request Mapping & HTTP Methods — Concept Check

Questions on Request Mapping & HTTP Methods. @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, and @PatchMapping are shortcuts for @RequestMapping(method=…) that map HTTP verbs to handler methods.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Request Mapping & HTTP Methods — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer is designing an API endpoint to update the status of an order. Which annotation should they use for this operation?

    • A@GetMapping
    • B@PatchMapping
    • C@DeleteMapping
    • D@PostMapping
  2. 2.You have a method annotated with @GetMapping("/products/{id}"). What HTTP method does this map to?

    • APOST
    • BPUT
    • CGET
    • DDELETE
  3. 3.A client sends a DELETE request to /api/orders/123. What should the server's response status be if the operation is successful?

    • A404 Not Found
    • B200 OK
    • C201 Created
    • D204 No Content
  4. 4.A developer mistakenly uses @PostMapping for a method intended to retrieve data. What issue might this cause?

    • AThe method will throw a runtime exception.
    • BThe method will return data in XML format.
    • CThe method will only accept JSON requests.
    • DThe method won't respond to GET requests.
  5. 5.A REST API endpoint is designed to replace an entire resource. Which annotation should be used?

    • A@PutMapping
    • B@GetMapping
    • C@PatchMapping
    • D@DeleteMapping
  6. 6.Which annotation would you use to handle file uploads in a Spring application?

    • A@DeleteMapping
    • B@PostMapping(consumes=MediaType.MULTIPART_FORM_DATA_VALUE)
    • C@PutMapping(consumes=MediaType.APPLICATION_JSON_VALUE)
    • D@GetMapping(produces=MediaType.MULTIPART_FORM_DATA_VALUE)
  7. 7.A method is annotated with @GetMapping(path="/files/*.txt"). What type of path matching does this demonstrate?

    • AURI template
    • BMatrix variable
    • CSingle-segment wildcard
    • DMulti-segment wildcard