Back-End Development Basics of Back End Development 5 — Questions and Answers
Question 1: What is the difference between authentication and authorization in a back-end system?
- Authentication checks what a user can do; authorization verifies who they are
- Authentication verifies identity; authorization determines what the verified user is allowed to do (Correct answer)
- They are synonyms for the same security check
- Authentication applies to APIs; authorization applies only to web pages
Correct answer: Authentication verifies identity; authorization determines what the verified user is allowed to do
Authentication confirms identity (who you are), while authorization determines permissions (what you are allowed to access or do).
Question 2: Which of the following is a common use case for caching in a back-end application?
- Storing user passwords in plain text for fast lookup
- Keeping frequently read, rarely changed data in memory to reduce database load (Correct answer)
- Permanently replacing the database for all read operations
- Encrypting API responses before sending them to the client
Correct answer: Keeping frequently read, rarely changed data in memory to reduce database load
Caching stores the results of expensive operations (e.g., DB queries or API calls) in fast storage like Redis so that repeated requests are served without hitting the database again.
Question 3: What is a foreign key in a relational database?
- An encrypted primary key used for secure joins
- A column that references the primary key of another table to enforce referential integrity (Correct answer)
- An index automatically created on every JOIN column
- A key generated by a third-party authentication provider
Correct answer: A column that references the primary key of another table to enforce referential integrity
A foreign key column stores values that match the primary key of a related table, ensuring that relationships between records remain consistent and valid.
Question 4: In a microservices architecture, what is service discovery used for?
- Automatically generating API documentation from source code
- Allowing services to dynamically find the network location of other services (Correct answer)
- Monitoring CPU and memory usage across all services
- Deploying new service versions without downtime
Correct answer: Allowing services to dynamically find the network location of other services
Service discovery lets services locate each other dynamically (via a registry like Consul or Kubernetes DNS) rather than relying on hard-coded addresses that change with deployments.
Question 5: What is the purpose of the HTTP OPTIONS method?
- To update a partial resource on the server
- To retrieve the communication options available for a resource, often used in CORS preflight (Correct answer)
- To delete all cached responses for a given URL
- To authenticate a client before sending sensitive data
Correct answer: To retrieve the communication options available for a resource, often used in CORS preflight
OPTIONS is used by browsers as a preflight request in CORS to ask the server which methods and headers it will accept before sending the actual cross-origin request.
Question 6: Which of the following describes eventual consistency in a distributed database?
- All reads always return the most recent write immediately
- Replicas may temporarily return stale data but will converge to the same value given no new updates (Correct answer)
- The database rolls back any write that cannot be confirmed by all nodes
- Consistency is guaranteed only for single-node deployments
Correct answer: Replicas may temporarily return stale data but will converge to the same value given no new updates
Eventual consistency allows replicas to temporarily diverge after a write, but guarantees they will converge to the same state once updates have propagated to all nodes.
Question 7: What is the main purpose of using HTTPS instead of HTTP for a back-end API?
- HTTPS compresses payloads automatically, reducing bandwidth
- HTTPS encrypts data in transit, protecting it from eavesdropping and tampering (Correct answer)
- HTTPS caches responses more efficiently than HTTP
- HTTPS eliminates the need for API authentication tokens
Correct answer: HTTPS encrypts data in transit, protecting it from eavesdropping and tampering
HTTPS uses TLS to encrypt the connection between client and server, ensuring that credentials, tokens, and data cannot be intercepted or modified in transit.
What is the difference between authentication and authorization in a back-end system?