Full-Stack Development Development Sample 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
- 202 Accepted
Correct answer: 201 Created
201 Created indicates that the request succeeded and a new resource was created as a result.
Question 2: In a React application, what hook would you use to perform a side effect like fetching data after a component renders?
- useState
- useContext
- useEffect (Correct answer)
- useReducer
Correct answer: useEffect
useEffect runs after the render cycle and is designed for side effects such as API calls and subscriptions.
Question 3: Which SQL clause is used to filter groups after a GROUP BY aggregation?
- WHERE
- FILTER
- HAVING (Correct answer)
- AND
Correct answer: HAVING
HAVING filters rows after aggregation, whereas WHERE filters rows before aggregation.
Question 4: What does the 'same-origin policy' restrict in web browsers?
- Cookie size limits
- JavaScript from reading responses from a different origin (Correct answer)
- Number of open WebSocket connections
- CSS from loading external fonts
Correct answer: JavaScript from reading responses from a different origin
The same-origin policy prevents scripts on one origin from accessing data from a different origin unless explicitly permitted by CORS headers.
Question 5: In Node.js, which module system is native and uses 'require()' to import files?
- ES Modules
- CommonJS (Correct answer)
- AMD
- UMD
Correct answer: CommonJS
CommonJS is Node.js's original module system, using require() and module.exports.
Question 6: What is the purpose of a database index?
- To encrypt data at rest
- To enforce foreign key constraints
- To speed up data retrieval queries (Correct answer)
- To compress table storage
Correct answer: To speed up data retrieval queries
An index creates a data structure that allows the database engine to locate rows faster without scanning the entire table.
Question 7: Which design pattern separates an application into Model, View, and Controller components?
- Observer
- Singleton
- MVC (Correct answer)
- Factory
Correct answer: MVC
MVC (Model-View-Controller) organizes code so that data logic, presentation, and input handling are kept separate.
Which HTTP status code should a REST API return when a resource is successfully created?