Full-Stack Development Developer 2 — Questions and Answers
Question 1: Which HTTP status code should a REST API return when a resource is successfully created?
- 200 OK
- 201 Created (Correct answer)
- 204 No Content
- 301 Moved Permanently
Correct answer: 201 Created
201 Created indicates that the request succeeded and a new resource was created as a result.
Question 2: In a Node.js application, what does the `process.env` object provide?
- Access to the file system
- Access to environment variables (Correct answer)
- Access to HTTP request headers
- Access to command-line arguments
Correct answer: Access to environment variables
`process.env` exposes environment variables set in the operating system or `.env` files to the Node.js process.
Question 3: What is the purpose of database indexing in full-stack applications?
- To encrypt sensitive data
- To speed up query performance on searched columns (Correct answer)
- To normalize table relationships
- To back up data automatically
Correct answer: To speed up query performance on searched columns
Indexes create data structures that allow the database engine to find rows faster without scanning the entire table.
Question 4: Which React hook should you use to run a side effect only once when a component mounts?
- useCallback
- useMemo
- useEffect with an empty dependency array (Correct answer)
- useRef
Correct answer: useEffect with an empty dependency array
Passing an empty array `[]` as the second argument to `useEffect` ensures it runs only after the initial render.
Question 5: What does CORS stand for and why is it relevant to full-stack development?
- Cross-Origin Resource Sharing; controls which domains can access your API (Correct answer)
- Client-Origin Request System; manages client authentication
- Cross-Origin Routing Schema; defines URL patterns
- Content-Origin Response Standard; formats API responses
Correct answer: Cross-Origin Resource Sharing; controls which domains can access your API
CORS is a browser security mechanism that restricts web pages from making requests to a different domain than the one that served the page.
Question 6: In SQL, what is the difference between `INNER JOIN` and `LEFT JOIN`?
- INNER JOIN returns all rows from both tables; LEFT JOIN returns only matching rows
- INNER JOIN returns only matching rows; LEFT JOIN returns all rows from the left table including unmatched (Correct answer)
- They are identical in behavior
- INNER JOIN works on indexed columns only; LEFT JOIN works on all columns
Correct answer: INNER JOIN returns only matching rows; LEFT JOIN returns all rows from the left table including unmatched
INNER JOIN returns only rows where there is a match in both tables, while LEFT JOIN returns all rows from the left table and matched rows from the right.
Question 7: What is JWT and what problem does it solve in web applications?
- JavaScript Web Template; a templating standard for server-side rendering
- JSON Web Token; a stateless way to transmit authentication information between parties (Correct answer)
- Java Web Toolkit; a library for building web UIs
- JSON Write Transfer; a protocol for syncing client and server state
Correct answer: JSON Web Token; a stateless way to transmit authentication information between parties
JWT is a compact, self-contained token format that allows servers to verify user identity without storing session data server-side.
Which HTTP status code should a REST API return when a resource is successfully created?