Spring Boot Interview Question

What is a REST API in Spring Boot?

Updated 2026-08-16 · Beginner friendly
Quick answer

A REST API is a way for clients to interact with your application over HTTP using standard methods on resources. In Spring Boot you build one with a RestController, mapping URLs to methods with GetMapping, PostMapping, and similar. GET reads data, POST creates, PUT updates, and DELETE removes, and responses are usually JSON.

Key takeaways
  • REST is an architectural style for APIs that uses HTTP methods on resources.
  • In Spring Boot you build REST APIs with RestController and mapping annotations.
  • Responses are usually JSON, and each resource has a clear URL.

The HTTP methods to resources

@RestController
@RequestMapping("/users")
class UserController {
    @GetMapping("/{id}")
    User get(@PathVariable int id) { return service.find(id); }

    @PostMapping
    User create(@RequestBody User u) { return service.save(u); }
}
In the interview

Mention PathVariable for values in the URL and RequestBody for data in the request body. Knowing which annotation reads which part of the request shows you can actually build endpoints, not just describe REST.

Frequently asked questions

How do you return JSON from a Spring Boot endpoint?

Return an object from a RestController method. Spring automatically converts it to JSON using a message converter like Jackson.

How do you read a path variable?

Use the PathVariable annotation on a method parameter to bind a value from the URL path, such as an id in /users/{id}.

Want the full Spring Boot guide?

Read every Spring Boot concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the Spring Boot guide All Spring Boot questions