Full-Stack Development Developer 4 — Questions and Answers
Question 1: What is the purpose of a reverse proxy (like Nginx) in front of a Node.js application?
- To compile JavaScript before serving it
- To handle SSL termination, load balancing, and static file serving (Correct answer)
- To replace the need for a database connection pool
- To transpile TypeScript on the fly
Correct answer: To handle SSL termination, load balancing, and static file serving
A reverse proxy sits in front of the application server to offload SSL, cache static assets, and distribute traffic across instances.
Question 2: In a REST API, what does idempotency mean, and which HTTP methods are idempotent?
- A request that always returns JSON; GET and POST
- Making the same request multiple times produces the same result; GET, PUT, and DELETE (Correct answer)
- A request that never changes server state; GET only
- A request that can be cached; GET and HEAD
Correct answer: Making the same request multiple times produces the same result; GET, PUT, and DELETE
Idempotent methods produce the same server state regardless of how many times they are called; GET, PUT, and DELETE all qualify.
Question 3: What is the event loop in Node.js and why does blocking it cause problems?
- A loop that polls the database every second; blocking it stops data refresh
- A single-threaded mechanism that processes I/O callbacks; blocking it halts all request handling (Correct answer)
- A background thread for CPU-intensive tasks; blocking it degrades memory
- A scheduler for cron jobs; blocking it delays scheduled tasks only
Correct answer: A single-threaded mechanism that processes I/O callbacks; blocking it halts all request handling
Node.js uses a single event loop thread; synchronous CPU-bound code blocks it and prevents any other requests from being processed.
Question 4: Which pattern does Redux follow, and what are its three core principles?
- Observer pattern; pub/sub, immutability, and lazy evaluation
- Flux pattern; unidirectional data flow, single store, and pure reducers (Correct answer)
- MVC pattern; model, view, and controller separation
- Factory pattern; single source of truth, schema validation, and caching
Correct answer: Flux pattern; unidirectional data flow, single store, and pure reducers
Redux implements Flux with a single immutable state tree, actions describing changes, and pure reducer functions that produce the next state.
Question 5: What problem does Docker solve for full-stack developers?
- It replaces version control for collaborative coding
- It packages an application with its environment so it runs consistently across machines (Correct answer)
- It automatically scales applications based on traffic
- It provides a cloud database without configuration
Correct answer: It packages an application with its environment so it runs consistently across machines
Docker containers bundle the application code, runtime, libraries, and config, eliminating 'works on my machine' environment inconsistencies.
Question 6: What is GraphQL's main advantage over REST for complex data requirements?
- GraphQL is always faster because it uses binary encoding
- Clients can request exactly the fields they need, avoiding over-fetching and under-fetching (Correct answer)
- GraphQL does not require a schema definition
- GraphQL automatically generates a frontend UI from the API
Correct answer: Clients can request exactly the fields they need, avoiding over-fetching and under-fetching
With GraphQL, the client specifies the exact shape of the data it needs in a single request, reducing payload size and round trips.
Question 7: Which of the following is a correct description of a microservices architecture?
- A single deployable unit containing all application logic
- An application split into small, independently deployable services that communicate over a network (Correct answer)
- A frontend framework for building micro-frontends
- A database sharding strategy for horizontal scaling
Correct answer: An application split into small, independently deployable services that communicate over a network
Microservices break an application into small, loosely coupled services that each own their domain and can be deployed, scaled, and updated independently.
What is the purpose of a reverse proxy (like Nginx) in front of a Node.js application?