Full-Stack Development Development Sample 5 — Questions and Answers
Question 1: What is the purpose of database migrations in a full-stack application?
- To back up data to cloud storage
- To version-control schema changes and apply them consistently across environments (Correct answer)
- To replicate data to a read replica
- To automatically generate REST endpoints from the schema
Correct answer: To version-control schema changes and apply them consistently across environments
Migrations track schema changes as code, enabling reproducible deployments and rollbacks across development, staging, and production.
Question 2: In async JavaScript, what does the Promise.all() method do when one of the promises rejects?
- It waits for all others to settle before rejecting
- It immediately rejects with the first rejection reason (Correct answer)
- It resolves with partial results from fulfilled promises
- It retries the failed promise automatically
Correct answer: It immediately rejects with the first rejection reason
Promise.all() uses 'fail-fast' behavior — the moment any promise rejects, the entire call rejects immediately.
Question 3: Which caching strategy serves cached content when available and only contacts the network when the cache is empty or stale?
- Network-first
- Cache-only
- Cache-first (cache falling back to network) (Correct answer)
- Stale-while-revalidate
Correct answer: Cache-first (cache falling back to network)
Cache-first checks the cache first and only fetches from the network if the item is missing or expired, minimizing network requests.
Question 4: What does the 'Single Responsibility Principle' (SRP) state about a module or class?
- It should only have one public method
- It should have only one reason to change (Correct answer)
- It should be used by only one other module
- It should never be instantiated more than once
Correct answer: It should have only one reason to change
SRP holds that a class or module should encapsulate one cohesive concern so that changes to one business rule affect only one unit.
Question 5: In a CI/CD pipeline, what is the purpose of a 'staging' environment?
- To host static assets closer to end users
- To test changes in a production-like environment before deploying to production (Correct answer)
- To store build artifacts permanently
- To run database migrations on production data
Correct answer: To test changes in a production-like environment before deploying to production
Staging mirrors production infrastructure so teams can validate behavior under realistic conditions before releasing to real users.
Question 6: Which WebSocket characteristic makes it preferable over HTTP polling for real-time features like chat?
- WebSockets use less RAM on the server
- WebSockets maintain a persistent bidirectional connection, eliminating repeated HTTP overhead (Correct answer)
- WebSockets are encrypted by default unlike HTTP
- WebSockets compress payloads automatically
Correct answer: WebSockets maintain a persistent bidirectional connection, eliminating repeated HTTP overhead
A WebSocket connection stays open so both parties can send messages at any time without the handshake overhead of repeated HTTP requests.
Question 7: What problem does an ORM (Object-Relational Mapper) solve in full-stack development?
- It converts JSON to XML for API interoperability
- It maps database rows to language objects, letting developers query without raw SQL (Correct answer)
- It automatically scales database read replicas
- It compresses images stored in the database
Correct answer: It maps database rows to language objects, letting developers query without raw SQL
An ORM bridges the gap between relational database rows and programming language objects, providing a higher-level query API.
What is the purpose of database migrations in a full-stack application?