Back-End Development Development 2 — Questions and Answers
Question 1: Which HTTP status code should an API return when a requested resource is not found?
- 200 OK
- 301 Moved Permanently
- 404 Not Found (Correct answer)
- 500 Internal Server Error
Correct answer: 404 Not Found
404 Not Found indicates the server could not locate the requested resource.
Question 2: In RESTful API design, which HTTP method is idempotent AND safe?
- POST
- PUT
- DELETE
- GET (Correct answer)
Correct answer: GET
GET is both idempotent (multiple identical requests produce the same result) and safe (it does not modify server state).
Question 3: What does the CAP theorem state about distributed systems?
- Consistency, Availability, and Partition tolerance cannot all be guaranteed simultaneously (Correct answer)
- Caching, Authentication, and Performance must be balanced
- Every database must choose between SQL and NoSQL
- CPU, API calls, and Persistence are the three pillars of scaling
Correct answer: Consistency, Availability, and Partition tolerance cannot all be guaranteed simultaneously
CAP theorem states a distributed system can guarantee at most two of the three properties: Consistency, Availability, and Partition tolerance.
Question 4: Which pattern separates the construction of a complex object from its representation?
- Singleton
- Observer
- Builder (Correct answer)
- Facade
Correct answer: Builder
The Builder pattern allows step-by-step construction of complex objects while keeping the construction process independent of the final representation.
Question 5: What is the primary purpose of database connection pooling in back-end applications?
- To encrypt database credentials
- To reuse existing database connections and reduce overhead (Correct answer)
- To automatically back up the database
- To distribute queries across multiple databases
Correct answer: To reuse existing database connections and reduce overhead
Connection pooling maintains a cache of reusable database connections, reducing the cost of repeatedly opening and closing connections.
Question 6: Which of the following best describes a microservices architecture?
- A single deployable unit containing all application logic
- An application built as a collection of small, independently deployable services (Correct answer)
- A pattern where all services share a single database
- A framework for building mobile back-ends
Correct answer: An application built as a collection of small, independently deployable services
Microservices decompose an application into small, independently deployable services that communicate over a network.
Question 7: What is the role of an API gateway in a microservices system?
- To store all service data in one place
- To act as a single entry point that routes requests to appropriate services (Correct answer)
- To compile microservices into a single binary
- To replace the need for load balancers
Correct answer: To act as a single entry point that routes requests to appropriate services
An API gateway serves as the single entry point for clients, handling routing, authentication, rate limiting, and aggregation across services.
Which HTTP status code should an API return when a requested resource is not found?