Sample questions
Question 1Easy
What does HTTP status code 404 mean?
- Not Found
- Internal Server Error
- Unauthorized
- Moved Permanently
Answer: A. Not Found
Explanation
4xx codes are client errors, and 404 means the server has no resource at that URL.
Step-by-step solution
- HTTP status codes in the 4xx range are client errors.
- 404 means the server has no resource at the requested URL.
- So 404 means Not Found, which is option A.
Why the other options are wrong
- B. 500 is Internal Server Error; 404 is a client-side error.
- C. 401 means Unauthorized, which is a different status code.
- D. 301 is Moved Permanently; 404 does not redirect.
Tip: 4xx means the client made a mistake; 5xx means the server failed.
Question 2Easy
Which HTTP method is meant to be safe and idempotent, used only to retrieve a resource?
- GET
- POST
- PATCH
- DELETE
Answer: A. GET
Explanation
GET only reads data and repeating it does not change server state.
Step-by-step solution
- Safe means no state change.
- Idempotent means repeats have the same effect.
- GET meets both.
Why the other options are wrong
- B. POST usually creates and is not idempotent.
- C. PATCH modifies a resource.
- D. DELETE removes a resource, so it is not safe.
Question 3Easy
Which HTTP method is not idempotent?
- DELETE
- PUT
- POST
- GET
Answer: C. POST
Explanation
Repeating an idempotent request has the same effect as sending it once. POST typically creates a new resource each time.
Step-by-step solution
- An idempotent request gives the same result when repeated.
- DELETE, PUT and GET are idempotent; repeating them does not change the result further.
- POST usually creates a new resource each time, so it is not idempotent; the answer is option C.
Why the other options are wrong
- A. Repeating a DELETE gives the same result, so it is idempotent.
- B. PUT sets a resource to a state, so repeating it gives the same state.
- D. GET only reads, so repeating it is safe and idempotent.
Tip: GET, PUT, DELETE are idempotent; POST usually is not.
Question 4Easy
What does the status family 5xx indicate?
- Client mistakes in the request
- Redirections
- Informational responses
- Server-side errors
Answer: D. Server-side errors
Explanation
5xx codes such as 500 or 503 mean the server failed to fulfil a valid request.
Step-by-step solution
- First digit gives the family.
- 5 means server error.
Why the other options are wrong
- A. That is the 4xx family.
- B. Redirects are 3xx.
- C. Those are 1xx.
Question 5Medium
What does it mean that a REST API is stateless?
- Each request is self-contained; no session is kept between requests
- The API is only allowed to use GET requests, never POST or PUT
- Responses can never be cached by browsers, clients or any proxies
- The server stores no data at all, not even in a database
Answer: A. Each request is self-contained; no session is kept between requests
Explanation
Statelessness means no per-client session context on the server, which makes scaling easier. Authentication is sent with each request, for example as a token.
Step-by-step solution
- REST statelessness means the server stores no client session between requests.
- Each request carries everything needed (auth token, parameters).
- It does not forbid databases, caching or other methods.
Why the other options are wrong
- B. REST uses many methods.
- C. Responses can be cached when marked cacheable.
- D. The server can still persist data.
Tip: Each request stands alone.
Question 6Medium
Which URL follows REST naming conventions to fetch the orders of user 7?
- GET /users/7/orders
- GET /getOrdersByUser?id=7
- POST /fetchOrders/7
- GET /order_list_for_user_seven
Answer: A. GET /users/7/orders
Explanation
REST uses nouns for resources, nesting for relationships, and the method for the action.
Step-by-step solution
- Use nouns, not verbs.
- Nest related resources.
Why the other options are wrong
- B. Verbs belong in the HTTP method, not the path.
- C. POST is not for reading, and the path has a verb.
- D. Hierarchical resource paths are conventional.
Question 7Medium
Which is a core REST constraint?
- The server must store the session between requests
- Every endpoint must use POST
- Statelessness: each request is self-contained
- Responses must be XML
Answer: C. Statelessness: each request is self-contained
Explanation
Stateless communication lets any server instance handle any request, aiding scaling.
Step-by-step solution
- No server-side session needed.
- Each request is self-contained.
Why the other options are wrong
- A. REST servers do not need client session state.
- B. REST uses HTTP methods by meaning.
- D. Any representation, commonly JSON, is allowed.
Question 8Medium
What is the difference between 401 and 403?
- 401 is a server error, while 403 is a client-side error
- 401: forbidden for everyone; 403: resource not found here
- 401: not authenticated; 403: authenticated but not allowed
- They are identical; servers may use either one for login
Answer: C. 401: not authenticated; 403: authenticated but not allowed
Explanation
401 Unauthorized asks the client to authenticate. 403 Forbidden means the server knows who you are and still refuses.
Step-by-step solution
- 401 Unauthorized means the client has not authenticated, so it should log in.
- 403 Forbidden means the server knows who the client is but refuses access.
- So 401 is not authenticated and 403 is authenticated but not allowed, which is option C.
Why the other options are wrong
- A. Both 401 and 403 are client-side (4xx) errors, not server errors.
- B. The meanings are swapped and wrong: 401 is about authentication, and 403 is about permission.
- D. They have different meanings, so they are not identical.
Tip: 401 means log in first; 403 means logging in will not help, because you lack permission.
Question 9Hard
What does the 304 Not Modified status mean?
- The resource has permanently moved
- The server refuses to process the request
- The cached copy is still valid, so no body is sent
- The request was malformed
Answer: C. The cached copy is still valid, so no body is sent
Explanation
304 is the reply to a conditional request when the resource has not changed since the cached version.
Step-by-step solution
- Conditional request sent.
- Unchanged resource.
- Server returns 304 with no body.
Why the other options are wrong
- A. That is 301.
- B. That would be 4xx.
- D. That is 400.
Question 10Hard
Which caching response header lets a client revalidate a stored response cheaply with If-None-Match?
- Content-Length
- Set-Cookie
- ETag
- Origin
Answer: C. ETag
Explanation
An ETag is a version identifier; the client sends it back and the server may reply 304 Not Modified.
Step-by-step solution
- Server sends ETag.
- Client sends If-None-Match.
- Server replies 304 if unchanged.
Why the other options are wrong
- A. It gives the size only.
- B. It stores cookies.
- D. It identifies the requesting site.
Practise all 23 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →