Recall & Review
beginner
What is the purpose of the
@RestController annotation in Spring Boot?The <code>@RestController</code> annotation marks a class as a controller where every method returns a domain object instead of a view. It combines <code>@Controller</code> and <code>@ResponseBody</code>, making it easier to create RESTful web services.Click to reveal answer
beginner
How does
@RestController differ from @Controller in Spring Boot?@RestController automatically serializes return objects to JSON or XML and sends them as HTTP responses. @Controller is used for web pages and requires explicit @ResponseBody to return data directly.Click to reveal answer
beginner
Can you use
@RestController on multiple classes in a Spring Boot application?Yes, you can use <code>@RestController</code> on multiple classes. Each class can handle different REST endpoints, helping organize your API logically.Click to reveal answer
intermediate
What HTTP response content type does
@RestController typically produce?@RestController typically produces JSON by default, but it can also produce XML or other formats if configured with message converters.Click to reveal answer
beginner
Why is
@RestController considered a convenience annotation?Because it combines
@Controller and @ResponseBody, reducing boilerplate code and making REST API development simpler and cleaner.Click to reveal answer
What does the
@RestController annotation do in Spring Boot?✗ Incorrect
@RestController is used to create REST APIs by returning data directly as JSON or XML.Which two annotations does
@RestController combine?✗ Incorrect
@RestController is a shortcut for @Controller plus @ResponseBody.What is the default format of data returned by methods in a
@RestController?✗ Incorrect
By default, Spring Boot converts returned objects to JSON in
@RestController methods.If you want to return a web page instead of data, which annotation should you use instead of
@RestController?✗ Incorrect
@Controller is used for returning views like HTML pages.Can a Spring Boot application have multiple classes annotated with
@RestController?✗ Incorrect
Multiple
@RestController classes help organize APIs logically.Explain what the
@RestController annotation does and why it is useful in Spring Boot applications.Think about how it simplifies returning data from web endpoints.
You got /4 concepts.
Describe the difference between
@RestController and @Controller in Spring Boot.Focus on what each annotation returns to the client.
You got /4 concepts.