Close
« Tutorial

Spring MVC - Using HttpEntity MCQ

0/13
0 ✓
0 ✗

1. What does HttpEntity encapsulate?

2. Which methods does HttpEntity provide to access its header and body?

3. HttpEntity is an alternative to using which two parameters?

4. Can HttpEntity be used as a handler method parameter?

5. What is the main advantage of using HttpEntity as a return value compared to @ResponseBody?

6. Given the method signature below, what type does getBody() return when handling a String body?

public HttpEntity<String> handleRequest(HttpEntity<String> requestEntity) { ... }

7. In the following code, what is the type of the body returned by getBody()?

public HttpEntity<User> handleUserRequest(HttpEntity<User> requestEntity) {
    User user = requestEntity.getBody();
    ...
}

8. Can HttpEntity be used to return a response with both a body and custom headers?

9. Which class does getHeaders() return?

10. Is HttpEntity specific to Spring MVC?

11. When HttpEntity is used as a handler method parameter, how are the request headers and body bound to it?

12. What is the difference between HttpEntity and @RequestBody?

13. Can HttpEntity be used for both reading a request and writing a response?

14. If you want to set a custom header in a response using HttpEntity, what should you do?

Join