1. What does the HTTP PATCH method do?
Why: The PATCH method is used to partially modify an existing resource at the requested URI.
2. What does the HTTP PUT method do?
Why: The PUT method creates the resource at the requested URI, or replaces it if it already exists.
3. What is the main difference between PUT and PATCH?
Why: PUT creates or replaces the whole resource, while PATCH applies a partial change to an existing resource.
4. A user wants to change only the email of an existing user record. All other fields should stay the same. Which HTTP method fits best?
Why: PATCH is made for partial updates. Only the changed data is sent, and the rest of the resource stays as it is.
5. Which HTTP method creates or modifies a resource without targeting a specific resource URI?
Why: POST does not target the URI of a specific resource. What happens to the resource afterward depends on the application logic.
6. Which Spring MVC annotation maps a controller method to HTTP PATCH requests?
Why: @PatchMapping is a shortcut annotation that maps HTTP PATCH requests to a handler method.
7. Which annotation is the same as @PatchMapping("/items")?
Why: @PatchMapping is a shortcut for @RequestMapping with method = RequestMethod.PATCH.
8. Which annotation gives a controller method access to the body of an HTTP request?
Why: @RequestBody binds the body of the HTTP request to a method parameter.
9. A PATCH request sends form data in its body. Which method parameter type can hold this data as keys, each with one or more values?
Why: MultiValueMap<String, String> stores each form field name as a key with a list of values. It can be used with @RequestBody to read form data.
10. Which content type is used for a request body that contains simple form data like id=1&content=hello?
Why: Form data written as name=value pairs joined by & uses the application/x-www-form-urlencoded content type.
11. A normal HTML form can only send GET or POST requests. How can a web page send an HTTP PATCH request?
Why: HTML forms support only GET and POST. To send a PATCH request from a browser page, you can use JavaScript, such as an AJAX call.
12. Which curl option sets the HTTP method to PATCH?
Why: The -X option tells curl which HTTP method to use, for example curl -X PATCH.
13. A controller method handles a PATCH request and returns the text "Updated" directly as the response body. Which annotation makes this possible?
Why: @ResponseBody tells Spring MVC to write the returned value directly to the response body instead of treating it as a view name.