Each HTTP method in a RESTful API maps to a specific type of operation on a resource, mirroring standard CRUD semantics.
For a /users/5 resource, GET /users/5 fetches the user, PUT /users/5 replaces the whole record, PATCH /users/5 updates just the email field, and DELETE /users/5 removes the account.
@GetMapping("/{id}")
public UserDto get(@PathVariable Long id) { ... }
@PutMapping("/{id}")
public UserDto replace(@PathVariable Long id, @RequestBody UserDto dto) { ... }
@PatchMapping("/{id}")
public UserDto update(@PathVariable Long id, @RequestBody Map<String, Object> fields) { ... }
@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) { ... }A concise interview answer is
GET reads without side effects, POST creates a new resource, PUT replaces a resource entirely and is idempotent, PATCH applies a partial update, and DELETE removes the resource. Mapping these onto CRUD keeps the API predictable and consistent with REST conventions.
Last updated: 11 November 2026
Previous question: What are the HTTP methods used in REST APIs?
Next question: You have a complex query that runs slowly in your Spring Boot application. How would you optimize it?