Understanding Status Codes: 2xx, 4xx, and 5xx Quiz Quiz

Explore the meanings and differences between HTTP 2xx, 4xx, and 5xx status codes with scenario-based questions. Strengthen your web development understanding by distinguishing successful responses, client errors, and server errors.

  1. Identifying a Successful Request

    After submitting an online form, you receive an HTTP response with status code 201. What does this status code indicate?

    1. A successful creation of a new resource
    2. A successful request with no content returned
    3. A client-side error due to a bad request
    4. A server error caused by gateway timeout

    Explanation: Status code 201 means that the request has succeeded and resulted in the creation of a new resource, often used when submitting forms that add data. 'A client-side error due to a bad request' refers to code 400, which is unrelated to creation. 'A server error caused by gateway timeout' relates to 504, a 5xx series code. 'A successful request with no content returned' is specifically code 204, not 201.

  2. Distinguishing a Client Error

    When accessing a web page, a visitor encounters an HTTP 404 status code. Which scenario best matches this code?

    1. The client is unauthorized to access the resource
    2. The server encountered an unexpected internal error
    3. The server could not find the requested resource
    4. The request was accepted and processed correctly

    Explanation: A 404 status code means the server cannot find the requested resource, typically when a URL is mistyped or the page has been deleted. 'The request was accepted and processed correctly' is represented by 200-series codes. 'The server encountered an unexpected internal error' is a 500 code, while 'the client is unauthorized to access the resource' refers to 401.

  3. Choosing the Correct 5xx Error Code

    If a server fails to fulfill a valid request due to an internal problem, which HTTP status code is most appropriate?

    1. 402 Payment Required
    2. 500 Internal Server Error
    3. 200 OK
    4. 403 Forbidden

    Explanation: The 500 Internal Server Error status code indicates a general server-side problem that prevented completing the request. '403 Forbidden' signals the client lacks necessary permissions. '402 Payment Required' is rarely used and not for server failures. '200 OK' means the request completed successfully, which is not the case here.

  4. Understanding the 2xx Series Range

    Which of the following is NOT a standard HTTP 2xx status code?

    1. 202 Accepted
    2. 206 Partial Content
    3. 208 Already Reported
    4. 204 No Content

    Explanation: While 202, 204, and 206 are all valid 2xx codes indicating various successful outcomes, 208 is less commonly used and specific to WebDAV, not part of the core HTTP statuses. This makes 208 the best answer here. The other codes are widely recognized and frequently encountered in routine web operations.

  5. Selecting the Best Status Code for Invalid User Input

    A user tries to submit a form but leaves a required field empty, resulting in a response. Which HTTP status code should the server use in this scenario?

    1. 201 Created
    2. 502 Bad Gateway
    3. 400 Bad Request
    4. 504 Gateway Timeout

    Explanation: The 400 Bad Request status code applies when the server cannot process a client request due to invalid input, such as missing required fields. '504 Gateway Timeout' and '502 Bad Gateway' indicate network or upstream server issues, not client input problems. '201 Created' is used when a resource is successfully created, which is not appropriate for this error.