Full-Stack Development Full-Stack Development Backend Systems & API Design 1 — Questions and Answers
Question 1: Which HTTP method is considered idempotent and is used to retrieve a resource without modifying it?
- POST
- GET (Correct answer)
- PATCH
- DELETE
Correct answer: GET
GET is idempotent and safe — it retrieves a resource without causing side effects, meaning repeated calls return the same result.
Question 2: In RESTful API design, what HTTP status code indicates that a new resource was successfully created?
- 200 OK
- 201 Created (Correct answer)
- 204 No Content
- 202 Accepted
Correct answer: 201 Created
201 Created is the standard response for a successful POST request that results in the creation of a new resource on the server.
Question 3: What does CORS stand for and why is it important in full-stack development?
- Cross-Origin Resource Sharing — controls which domains can make requests to your API (Correct answer)
- Content Origin Response System — caches API responses at the CDN level
- Cross-Object Routing Service — maps URLs to controller methods
- Client-Origin Request Schema — validates request payloads
Correct answer: Cross-Origin Resource Sharing — controls which domains can make requests to your API
CORS is a browser security mechanism that restricts cross-origin HTTP requests, requiring servers to explicitly allow requests from different domains.
Question 4: Which Node.js framework is most commonly used to build RESTful APIs due to its minimal and unopinionated design?
- NestJS
- Express.js (Correct answer)
- Fastify
- Hapi
Correct answer: Express.js
Express.js is the most widely used Node.js web framework, known for its minimalist design, middleware system, and large ecosystem.
Question 5: What is the purpose of HTTP middleware in an Express.js application?
- To compile TypeScript before the server starts
- To intercept and process requests/responses in a pipeline before reaching the route handler (Correct answer)
- To cache database query results
- To manage environment variables
Correct answer: To intercept and process requests/responses in a pipeline before reaching the route handler
Middleware functions in Express execute in order on each request, allowing you to add logging, authentication, parsing, and error handling before route handlers run.
Question 6: What does GraphQL provide over a traditional REST API?
- Faster response times due to binary encoding
- Clients can request exactly the fields they need, reducing over-fetching and under-fetching (Correct answer)
- Automatic database schema generation
- Built-in authentication and authorization
Correct answer: Clients can request exactly the fields they need, reducing over-fetching and under-fetching
GraphQL lets clients specify exactly which fields to return in a query, solving the REST problems of over-fetching (too much data) and under-fetching (too many requests).
Which HTTP method is considered idempotent and is used to retrieve a resource without modifying it?