JavaThinking.com
Toggle Menu
Home
Online Kotlin Compiler
Tutorials
Spring Boot
Spring Cloud
Spring Data
Spring MVC
Spring Security
Blog
All Posts
Spring RESTful Services
Assess your ability to design and implement REST APIs with Spring MVC.
1. Which annotation is used to mark a class as a REST controller in Spring, combining @Controller and @ResponseBody?
@Controller
@RestController
@Service
@Repository
2. What HTTP method is typically associated with the @PostMapping annotation in Spring?
GET
POST
PUT
DELETE
3. Which annotation is used to extract a path variable from the URL in a Spring REST method?
@RequestParam
@PathVariable
@RequestBody
@ResponseBody
4. What is the default response format for a Spring REST controller method returning a Java object?
XML
JSON
HTML
CSV
5. Which Spring Boot starter is required to build RESTful web services?
spring-boot-starter-web
spring-boot-starter-data-jpa
spring-boot-starter-security
spring-boot-starter-test
6. What HTTP status code is returned by default when a Spring REST resource is not found?
200 OK
404 Not Found
500 Internal Server Error
400 Bad Request
7. Which annotation is a shortcut for @RequestMapping(method = RequestMethod.GET)?
@GetMapping
@PostMapping
@PutMapping
@DeleteMapping
8. Which class is the entry point for a Spring Boot REST application?
RestController
ApplicationConfig
SpringBootApplication
DispatcherServlet
9. Which HTTP methods are typically used for modifying resources in RESTful services? (Select all that apply)
GET
POST
PUT
DELETE
PATCH
10. Which Spring annotations can be used to handle request data? (Select all that apply)
@RequestParam
@PathVariable
@RequestBody
@RequestHeader
@ResponseBody
11. Which are valid HTTP status codes for successful REST responses? (Select all that apply)
200 OK
201 Created
404 Not Found
204 No Content
500 Internal Server Error
12. Which features does Spring Boot provide to simplify REST development? (Select all that apply)
Auto-configuration
Manual XML configuration
Embedded server
Starter dependencies
Explicit DispatcherServlet setup
13. Which exceptions can Spring REST handle using @ExceptionHandler? (Select all that apply)
NullPointerException
ResourceNotFoundException
HttpRequestMethodNotSupportedException
ClassCastException
HttpMessageNotReadableException
14. @RestController includes @ResponseBody, so methods in a @RestController do not need explicit @ResponseBody.
True
False
15. Spring Boot requires explicit configuration of Jackson for JSON serialization in REST controllers.
True
False
16. @RequestMapping can be applied at both class and method levels to define URL paths.
True
False
17. The @ResponseStatus annotation can only set status codes for successful responses.
True
False
18. What does REST stand for in the context of web services?
19. Name the annotation used to inject the HTTP request body into a method parameter (abbrev.)
20. What property in application.properties configures the port of a Spring Boot REST application?
Reset
Answered 0 of 0 — 0 correct