API REST API Fundamentals 2 — Questions and Answers
Question 1: Which HTTP method is used to retrieve headers without a response body?
- GET
- OPTIONS
- HEAD (Correct answer)
- TRACE
Correct answer: HEAD
HEAD returns only headers identical to a GET request but omits the response body.
Question 2: What is the purpose of the OPTIONS HTTP method?
- Delete a resource
- Describe communication options for the target (Correct answer)
- Update a resource
- Retrieve cached data
Correct answer: Describe communication options for the target
OPTIONS describes the communication options available for the target resource, commonly used in CORS preflight requests.
Question 3: Which HTTP status code range indicates client-side errors?
- 1xx
- 2xx
- 3xx
- 4xx (Correct answer)
Correct answer: 4xx
4xx status codes indicate client-side errors such as bad requests, unauthorized access, or not found.
Question 4: What does a 500 Internal Server Error typically indicate?
- Invalid request format
- Resource not found
- An unexpected condition on the server (Correct answer)
- Unauthorized access
Correct answer: An unexpected condition on the server
500 Internal Server Error means the server encountered an unexpected condition that prevented it from fulfilling the request.
Question 5: Which constraint of REST requires that each request contain all information needed to process it?
- Cacheability
- Statelessness (Correct answer)
- Layered system
- Uniform interface
Correct answer: Statelessness
Statelessness means each client request must contain all necessary information, and the server stores no client session state.
Question 6: What media type is most commonly used in REST API responses?
- text/html
- application/xml
- application/json (Correct answer)
- text/plain
Correct answer: application/json
application/json is the most widely used media type for REST API responses due to its lightweight and readable format.
Which HTTP method is used to retrieve headers without a response body?