DNS, HTTP & HTTPS Questions with Answers

37 practice questions on DNS, HTTP & HTTPS (Computer Networks) with answers and step-by-step solutions. Try 10 samples below, then practise all 37 free in the AptiNest app.

Sample questions

Question 1Easy

In the URL https://shop.example.com:8443/cart?id=7#top, what is the port?

  1. 80
  2. 8443
  3. 443
  4. 7

Answer: B. 8443

Explanation

An explicit port follows the host after a colon; without it, HTTPS would default to 443.

Step-by-step solution

  1. The URL is https://shop.example.com:8443/cart?id=7#top.
  2. Port number comes after the host name and a colon.
  3. Host is shop.example.com, port is 8443.
  4. 8443 is the explicit port specified in the URL.
  5. Final answer: 8443.

Why the other options are wrong

  • A. 80 is the default HTTP port, but this URL names port 8443 explicitly.
  • C. 443 is the default HTTPS port, but this URL sets port 8443 explicitly.
  • D. 7 is the value of the id query parameter, not the port.

Tip: Look for the colon and number after the domain in the URL to find the port.

Question 2Easy

What does HTTP status 301 indicate?

  1. The request was successful
  2. The server is temporarily overloaded
  3. The resource has moved permanently
  4. Authentication is required

Answer: C. The resource has moved permanently

Explanation

301 Moved Permanently gives a new URL in the Location header; 302/307 are temporary redirects.

Step-by-step solution

  1. 3xx codes tell the client to look somewhere else for the resource.
  2. 301 specifically means the resource has moved permanently, with the new URL in the Location header.
  3. 302 and 307 instead signal a temporary move, so the client should keep using the old URL next time.

Why the other options are wrong

  • A. A successful request would return a 2xx code, not 301.
  • B. A temporarily overloaded server returns a 5xx code like 503, not 301.
  • D. Authentication required is signalled by 401, not 301.

Tip: 301 = permanent (update your bookmark), 302/307 = temporary (keep the old link).

Question 3Easy

Which HTTP status code means the request succeeded and a new resource was created?

  1. 201
  2. 202
  3. 204
  4. 200

Answer: A. 201

Explanation

201 Created usually comes with a Location header pointing to the new resource.

Step-by-step solution

  1. 2xx codes all mean success, but each one is more specific.
  2. 200 is the generic 'OK'.
  3. 201 specifically means a new resource was created, usually with a Location header pointing to it.

Why the other options are wrong

  • B. 202 Accepted means the request was accepted for later processing, not that a resource now exists.
  • C. 204 No Content means success with nothing to return in the body.
  • D. 200 OK is the generic success code; it does not specifically signal that something new was created.

Tip: 200 = generic success, 201 = created, 202 = accepted (pending), 204 = success, no body.

Question 4Easy

Which class of HTTP status codes indicates a server-side error?

  1. 2xx
  2. 5xx
  3. 3xx
  4. 4xx

Answer: B. 5xx

Explanation

- 4xx means the client made an error (e.g. 404);
- 5xx means the server failed (e.g. 500, 503).

Step-by-step solution

  1. The leading digit of an HTTP status code gives its category.
  2. 4xx means the client made a mistake (bad request, not found, etc.).
  3. 5xx means the server itself failed to handle a valid request, such as 500 or 503.

Why the other options are wrong

  • A. 2xx codes mean success, not an error.
  • C. 3xx codes are redirects, not errors.
  • D. 4xx codes mean the client made the mistake, not the server.

Tip: First digit tells the story: 2 ok, 3 redirect, 4 your fault, 5 their fault.

Question 5Medium

DNS queries are usually sent over which transport protocol and port?

  1. UDP port 53
  2. TCP port 80
  3. TCP port 25
  4. UDP port 67

Answer: A. UDP port 53

Explanation

Normal DNS lookups use UDP 53; TCP 53 is used for large responses and zone transfers. UDP 67 is DHCP and TCP 25 is SMTP.

Step-by-step solution

  1. Normal DNS lookups use UDP for speed, since most queries and answers are small.
  2. DNS listens on port 53.
  3. TCP port 53 is used only when a response is too large for UDP or for zone transfers.

Why the other options are wrong

  • B. HTTP uses TCP port 80, which is unrelated to DNS lookups.
  • C. TCP port 25 is SMTP (mail), not DNS.
  • D. UDP port 67 is DHCP server traffic, not DNS.

Tip: UDP 53 = everyday DNS queries; TCP 53 = zone transfers or oversized responses.

Question 6Medium

Which DNS record type is used for reverse lookups (IP address to hostname)?

  1. TXT
  2. A
  3. PTR
  4. MX

Answer: C. PTR

Explanation

Reverse lookups query names under in-addr.arpa (IPv4) or ip6.arpa (IPv6) for PTR records.

Step-by-step solution

  1. Reverse DNS flips the usual direction: given an IP address, find its hostname.
  2. It works by querying a special reverse zone (in-addr.arpa for IPv4, ip6.arpa for IPv6).
  3. That zone holds PTR records mapping the address back to a name.

Why the other options are wrong

  • A. TXT records hold arbitrary text, such as SPF policies, not reverse mappings.
  • B. A records go forward, from name to IPv4 address, the opposite direction.
  • D. MX lists mail servers, unrelated to reverse lookups.

Tip: Forward lookup: name to IP (A/AAAA). Reverse lookup: IP to name (PTR).

Question 7Medium

Of the following HTTP methods, which one is not idempotent?

  1. GET
  2. DELETE
  3. PUT
  4. POST

Answer: D. POST

Explanation

Repeating a POST may create duplicate resources; repeating PUT or DELETE leaves the same final state.

Step-by-step solution

  1. Idempotent means repeating the request leaves the system in the same final state as doing it once.
  2. GET just reads, PUT replaces with the same data, and DELETE leaves the resource gone either way, so all three are idempotent.
  3. POST typically creates something new each time it runs, so repeating it can create duplicate resources.

Why the other options are wrong

  • A. GET is idempotent; reading data again does not change anything.
  • B. Repeating DELETE on an already-deleted resource still leaves it deleted, the same end state.
  • C. Repeating PUT with the same data leaves the resource in the same final state.

Tip: GET/PUT/DELETE: safe to retry blindly. POST: retry carefully, it can duplicate effects.

Question 8Medium

Which HTTP method returns only the headers that a GET would return, without the body?

  1. PATCH
  2. OPTIONS
  3. HEAD
  4. TRACE

Answer: C. HEAD

Explanation

HEAD is useful for checking existence, size or modification time without downloading the resource.

Step-by-step solution

  1. HEAD method sends request headers only, like GET but no body.
  2. It retrieves response headers without the actual content body.
  3. This helps check metadata like size or modification time quickly.
  4. HEAD is designed for resource validation without transferring data.
  5. So HEAD returns only headers as required in the question.

Why the other options are wrong

  • A. PATCH partially updates a resource and returns a response; it is not a header-only GET.
  • B. The OPTIONS method asks which methods a server supports; it does not return GET headers.
  • D. TRACE echoes the received request back for debugging; it does not return the headers of a GET.

Tip: Remember: HEAD gives headers only, no body. Use it for quick checks.

Question 9Hard

Why is HTTP described as stateless even though websites keep users logged in?

  1. The server keeps every TCP connection open forever
  2. Each request stands alone; cookies add state
  3. TLS keeps the login state between requests, so no cookies are needed
  4. DNS remembers each user

Answer: B. Each request stands alone; cookies add state

Explanation

The protocol itself carries no memory between requests, so applications send an identifier (cookie or token) with each request.

Step-by-step solution

  1. HTTP does not remember previous interactions by default.
  2. Websites use cookies to track login state across requests.
  3. Each HTTP request is treated as a new session.
  4. Cookies are sent with each request to maintain state.
  5. So, the correct answer is: Each request stands alone; cookies add state.

Why the other options are wrong

  • A. Connections are not kept open forever; HTTP does not depend on a permanent TCP link.
  • C. TLS encrypts the traffic; it does not keep application login state between requests.
  • D. DNS maps names to addresses and does not track individual users.

Tip: Remember: HTTP itself has no memory—state is managed by cookies or tokens.

Question 10Hard

A company wants example.com itself (the zone apex) to point to a hosting provider. Why can it not simply use a CNAME at the apex?

  1. CNAMEs are limited to mail servers
  2. CNAME records work only for IPv6 addresses and the provider gives an IPv4 address
  3. Apex names cannot be resolved
  4. The apex needs SOA/NS, and a CNAME allows no other records

Answer: D. The apex needs SOA/NS, and a CNAME allows no other records

Explanation

A name with a CNAME may have no other data; the zone apex always needs SOA and NS, so providers offer ALIAS/flattening instead.

Step-by-step solution

  1. A DNS rule says a name with a CNAME record may have no other record types.
  2. The zone apex, such as example.com itself, must always carry SOA and NS records.
  3. So the apex can never also be a CNAME; providers instead offer ALIAS or ANAME-style records that behave similarly but are not true CNAMEs.

Why the other options are wrong

  • A. CNAMEs are not limited to mail records at all; that is not the restriction here.
  • B. CNAMEs work regardless of IPv4 or IPv6; address family is not the issue.
  • C. Apex names can absolutely be resolved; that is not the problem being described.

Tip: Rule of thumb: never put a CNAME at a zone apex; use the provider's ALIAS/ANAME feature instead.

Practise all 37 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 →

Related topics

See all Computer Networks topics · All topics