REST API Design Multiple Choice Quiz 3

  1. What is the primary purpose of the Vary header in HTTP responses?
    • a) To specify which headers were used for content negotiation
    • b) To indicate the API version
    • c) To authenticate the client
    • d) To specify the caching duration
  2. Which of the following is NOT a common method for API versioning?
    • a) URL path versioning
    • b) Query parameter versioning
    • c) Header versioning
    • d) Body versioning
  3. What is the main advantage of using cursor-based pagination over offset-based pagination?
    • a) Simplicity
    • b) Consistency with large datasets
    • c) Better performance
    • d) Easier implementation
  4. Which HTTP status code should be returned when a request is rate-limited?
    • a) 401 Unauthorized
    • b) 403 Forbidden
    • c) 429 Too Many Requests
    • d) 503 Service Unavailable
  5. What is the purpose of the OPTIONS method in CORS?
    • a) To retrieve a resource
    • b) To update a resource
    • c) To check which HTTP methods and headers are allowed
    • d) To delete a resource
  6. Which of the following is NOT a typical characteristic of a RESTful API?
    • a) Stateless
    • b) Client-Server
    • c) Layered System
    • d) Continuous Connection
  7. What is the main purpose of using JWT (JSON Web Tokens) in API authentication?
    • a) To encrypt API responses
    • b) To compress API requests
    • c) To provide a stateless authentication mechanism
    • d) To implement API versioning
  8. Which HTTP method is considered safe?
    • a) POST
    • b) PUT
    • c) DELETE
    • d) GET
  9. What is the purpose of the Link header in HTTP responses?
    • a) To provide hypermedia controls
    • b) To specify the content type
    • c) To indicate the API version
    • d) To authenticate the client
  10. Which of the following is a benefit of using Protocol Buffers over JSON?
    • a) Human readability
    • b) Wide browser support
    • c) Smaller message size and faster processing
    • d) Easier to implement on the server-side
  11. What is the main purpose of API throttling?
    • a) To increase API security
    • b) To improve API performance
    • c) To limit the rate of API requests
    • d) To implement API versioning
  12. Which HTTP status code indicates that the request was valid, but the server is refusing to respond to it?
    • a) 400 Bad Request
    • b) 401 Unauthorized
    • c) 403 Forbidden
    • d) 404 Not Found
  13. What is the purpose of the If-None-Match header?
    • a) To implement conditional requests based on the ETag
    • b) To specify the desired response format
    • c) To indicate the API version
    • d) To authenticate the request
  14. Which of the following is NOT a common authentication method for APIs?
    • a) Basic Authentication
    • b) API Keys
    • c) OAuth 2.0
    • d) SOAP Authentication
  15. What is the main advantage of using long-polling over traditional polling?
    • a) Reduced server load
    • b) Real-time updates
    • c) Improved security
    • d) Easier implementation
  16. Which HTTP method is used to perform a partial update of a resource?
    • a) GET
    • b) POST
    • c) PUT
    • d) PATCH
  17. What is the purpose of the Retry-After header?
    • a) To indicate when to retry a failed request
    • b) To specify the content type
    • c) To authenticate the client
    • d) To indicate the API version
  18. Which of the following is a characteristic of a well-designed URI?
    • a) It contains the HTTP method
    • b) It includes query parameters for essential data
    • c) It is short and meaningful
    • d) It always ends with a file extension
  19. What is the main purpose of using WebSockets in API design?
    • a) To improve security
    • b) To enable real-time, bidirectional communication
    • c) To implement API versioning
    • d) To compress API responses
  20. Which status code should be returned when the request entity is larger than the server is willing or able to process?
    • a) 400 Bad Request
    • b) 413 Payload Too Large
    • c) 415 Unsupported Media Type
    • d) 431 Request Header Fields Too Large