Full-Stack Development Development Sample 4 — Questions and Answers
Question 1: Which HTTP method is considered idempotent AND safe (read-only) according to the HTTP specification?
- POST
- PUT
- GET (Correct answer)
- PATCH
Correct answer: GET
GET is both safe (does not modify state) and idempotent (repeating it has the same result), making it ideal for data retrieval.
Question 2: In a relational database, what constraint ensures that a column's value in one table matches a primary key in another table?
- UNIQUE constraint
- CHECK constraint
- FOREIGN KEY constraint (Correct answer)
- NOT NULL constraint
Correct answer: FOREIGN KEY constraint
A FOREIGN KEY constraint enforces referential integrity by requiring that the referenced value exists in the parent table.
Question 3: What does 'tree shaking' do in a JavaScript bundler like Webpack or Rollup?
- Minifies CSS by removing whitespace
- Eliminates unused exported code from the final bundle (Correct answer)
- Splits code into separate chunks for lazy loading
- Inlines critical CSS into HTML
Correct answer: Eliminates unused exported code from the final bundle
Tree shaking statically analyzes import/export statements and removes code paths that are never imported or called.
Question 4: Which React concept allows a component to share state logic without using inheritance?
- Higher-Order Component (HOC) (Correct answer)
- Class inheritance
- Direct prop mutation
- Document fragment
Correct answer: Higher-Order Component (HOC)
A Higher-Order Component wraps another component and injects shared behavior or data as props, enabling logic reuse.
Question 5: What is a JWT (JSON Web Token) primarily used for in a full-stack application?
- Encrypting database passwords
- Transmitting claims securely between parties for authentication/authorization (Correct answer)
- Compressing API response payloads
- Storing session data server-side
Correct answer: Transmitting claims securely between parties for authentication/authorization
JWTs encode claims in a signed, compact token so servers can verify identity without storing session state.
Question 6: In CSS Flexbox, which property on the flex container defines the main axis direction?
- align-items
- flex-wrap
- flex-direction (Correct answer)
- justify-self
Correct answer: flex-direction
flex-direction sets whether flex items are laid out in a row or column, defining the main and cross axes.
Question 7: Which approach does GraphQL use to solve the over-fetching and under-fetching problems common in REST APIs?
- Versioned endpoints for each resource shape
- Clients specify exactly the fields they need in the query (Correct answer)
- Server pushes all data proactively via WebSockets
- Pagination is required on every request
Correct answer: Clients specify exactly the fields they need in the query
GraphQL lets clients declare the exact fields they require, so the server returns precisely that data — no more, no less.
Which HTTP method is considered idempotent AND safe (read-only) according to the HTTP specification?