Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 1 MCQsRefreshing JavaScript and React Fundamentals
Object spread performs a shallow copy. Both objects still reference the same nested settings object.
Question 26 of 60 · ES modules · Medium
A file named app.js contains export default function App() {} and export const version = '1.0';. Which statement correctly imports both exports?
Not quite. Try another option.
Answer: import App, { version } from './app.js';
A default export is imported without braces, while a named export such as version is imported using braces.
Question 27 of 60 · Immutability principles · Medium
Given state shaped as { name: 'Lee', profile: { city: 'Delhi', timezone: 'IST' } }, which update changes only the city while preserving all other fields and references appropriately?
The function depends only on its input and does not mutate data or rely on changing external values.
Question 29 of 60 · Shallow and deep copying mechanisms · Medium
An object contains nested arrays and a Date. Which approach creates an independent deep copy while preserving the Date as a Date in modern browsers?
Not quite. Try another option.
Answer: const copy = structuredClone(original);
structuredClone deeply copies supported values, including nested arrays and Date objects. JSON copying converts dates to strings.
Question 30 of 60 · Referential equality and state comparison · Medium
Consider an array state update:
const next = current;
next.push('B');
setItems(next);
Which statement best describes the problem?
Not quite. Try another option.
Answer: Object.is(current, next) is true, so React may skip the update.
next and current are the same array reference. React state comparisons use referential equality rather than deep element comparison.
Question 31 of 60 · Single Page Applications and Multi Page Applications · Medium
A dashboard must update its URL and switch views after initial loading without requesting a new HTML document for each navigation. Which architecture best matches this requirement?
Not quite. Try another option.
Answer: An SPA using client-side routing
An SPA typically loads one document and uses client-side routing to change views and URLs without full-page document requests.
Question 32 of 60 · React philosophy and declarative UI paradigm · Medium
Which implementation most clearly follows React's declarative UI approach for displaying an online status?
Declarative code describes the UI for each state and lets React update the DOM to match that description.
Question 33 of 60 · Component-based architecture · Medium
A product card containing an image, title, price, and add button appears on several pages. What is the best component-based design?
Not quite. Try another option.
Answer: Create a reusable ProductCard that receives product data and an add handler.
Extracting repeated UI into a configurable component improves reuse, consistency, testing, and maintenance.
Question 34 of 60 · Setting up React applications using Vite · Medium
Which command sequence creates and starts a React project using Vite?
Not quite. Try another option.
Answer: npm create vite@latest my-app -- --template react, then cd my-app, npm install, and npm run dev
create-vite scaffolds the React template, dependencies are installed with npm, and the Vite development server is started with npm run dev.
Question 35 of 60 · Modern React development environment and tooling · Medium
In a standard Vite React project, which command creates optimized production assets, usually in the dist directory?
Not quite. Try another option.
Answer: npm run build
npm run build runs Vite's production build. dev starts development, preview serves an existing build, and lint checks code.
Question 36 of 60 · Feature-based project folder structure and best practices · Medium
An application has checkout-specific components and hooks plus a generic Button used throughout the application. Which organization best follows a feature-based structure?
Not quite. Try another option.
Answer: Place checkout code in features/checkout and Button in shared/components.
Feature-owned code should be colocated, while genuinely reusable components belong in a shared area.
Question 37 of 60 · JSX syntax and expressions · Medium
Which JSX expression displays No items when count is 0 and displays 3 items when count is 3?
createRoot receives the existing DOM container, and its render method receives the React element.
Question 39 of 60 · Functional components and render lifecycle · Medium
A functional component receives userId as a prop and should load user data after the component is committed whenever userId changes. Which implementation is appropriate?
An effect runs after rendering, and listing userId makes it rerun when that dependency changes without running after every commit.
Question 40 of 60 · Introduction to Virtual DOM and reconciliation process · Medium
A rendered list can be reordered and its items have stable database IDs. Which key best helps React reconcile the list while preserving the correct item state?
Not quite. Try another option.
Answer: <Row key={item.id} item={item} />
A stable unique ID lets reconciliation match each previous element with the same logical item after reordering. Unstable keys cause unnecessary remounting.
base excludes the destructured id. The patch overrides active and temporarily adds id: 9, but the final id shorthand overwrites it with the original value 1.
Answer: 0 followed by 1, because imported bindings are live.
Named imports are live read-only views of bindings in the exporting module. increment() changes the binding inside counter.js, and the imported view reflects that change.
Question 47 of 60 · Immutability principles · Hard
Given state = { user: { profile: { name: "Lin" }, permissions: ["read"] }, settings: { theme: "dark" } }, which update changes the name to "Ada" without mutation while preserving the original settings and permissions references?
Only objects along the modified path must be copied. Unchanged branches such as settings and permissions can safely retain their original references.
Question 48 of 60 · Functional programming concepts relevant to React · Hard
A component must return products sorted by ascending score without mutating the items prop and while retaining each product object's identity. Which expression satisfies those requirements?
Not quite. Try another option.
Answer: [...items].sort((a, b) => a.score - b.score)
Spreading creates a new array before sort() mutates it. The product objects themselves are reused, so their identities remain unchanged.
Question 49 of 60 · Shallow and deep copying mechanisms · Hard
Object spread is shallow, so shallow.nested aliases original.nested. structuredClone() recursively copies the supported nested objects and arrays.
Question 50 of 60 · Referential equality and state comparison · Hard
A React component executes state.user.name = "Ada"; setState(state);, where state is the current object from useState. Which outcome best describes the problem?
Not quite. Try another option.
Answer: React can bail out because the state reference is unchanged.
React compares the new state with the current state using Object.is. Reusing the same reference can cause a bailout even though the object was mutated.
Question 51 of 60 · Single Page Applications and Multi Page Applications · Hard
An application has many URLs, uses the History API for navigation, loads route-specific JavaScript chunks, retrieves data through APIs, and keeps the same document alive between routes. How should it be classified?
Not quite. Try another option.
Answer: As an SPA, because client-side navigation reuses one document.
The defining feature is the document lifecycle, not the number of URLs or chunks. Client-side route transitions that preserve the document are characteristic of an SPA.
Question 52 of 60 · React philosophy and declarative UI paradigm · Hard
A component directly changes a rendered element using document.querySelector(...).textContent = "Saved". After an unrelated state update, React restores the previous text. What best explains this behavior?
Not quite. Try another option.
Answer: React treats rendered output as a declaration and reconciles the DOM back to that output.
React expects the DOM to be derived from props and state. Out-of-band mutations can be overwritten when reconciliation applies the latest declared UI.
Question 53 of 60 · Component-based architecture · Hard
Two sibling components must display and update the same selected product, while a third sibling only reads it. Which design best preserves a single source of truth?
Not quite. Try another option.
Answer: Store the selection in their nearest common ancestor and pass values and callbacks.
Lifting shared state to the nearest common owner keeps one authoritative value. Children receive state through props and request updates through callbacks.
Question 54 of 60 · Setting up React applications using Vite · Hard
A Vite React project defines VITE_API_URL=https://api.example.com in the applicable environment file. Which client-side expression accesses the value correctly?
Not quite. Try another option.
Answer: import.meta.env.VITE_API_URL
Vite exposes client variables prefixed with VITE_ through import.meta.env. Such values are generally provided as strings.
Question 55 of 60 · Modern React development environment and tooling · Hard
Which statement accurately distinguishes Vite's development server from its production build process?
Not quite. Try another option.
Answer: Development serves transformed modules on demand; production bundles and optimizes assets.
Vite's development workflow uses fast on-demand module transformation and HMR. Its production build performs bundling, optimization, and asset generation.
Question 56 of 60 · Feature-based project folder structure and best practices · Hard
In a feature-based application, checkout needs a stable selector owned by the cart feature. Which import strategy best protects feature boundaries?
Not quite. Try another option.
Answer: Import it from the public API exposed by features/cart.
A feature's public entry point exposes supported dependencies while hiding internal structure. This reduces coupling and permits internal refactoring.
Question 57 of 60 · JSX syntax and expressions · Hard
What visible content is produced by <div>{count && <span>New</span>}</div> when count is the number 0?
Not quite. Try another option.
Answer: A div containing the text 0.
The && expression evaluates to 0. React omits booleans, null, and undefined, but numbers—including zero—are rendered as text.
Question 58 of 60 · Rendering components into the DOM · Hard
What is the semantic effect of calling root.render(<App mode="light" />) and then root.render(<App mode="dark" />) on the same root?
Not quite. Try another option.
Answer: The second call updates the existing root rather than appending another application.
A React root represents one managed tree. Rendering again schedules an update to that tree, with the latest element becoming its requested UI.
Question 59 of 60 · Functional components and render lifecycle · Hard
Which statement about functional component rendering and effects remains valid under concurrent rendering and development StrictMode?
Not quite. Try another option.
Answer: A render may be abandoned; effects run after commit, with cleanup before rerun or unmount.
Rendering must remain pure because React may restart or discard render work. Effects belong to the commit phase, and their cleanup handles dependency changes and unmounting.
Question 60 of 60 · Introduction to Virtual DOM and reconciliation process · Hard
A list of stateful row components is reordered. Each row currently uses its array index as key. What is the most likely reconciliation issue, and what is the correct remedy?
Not quite. Try another option.
Answer: State may follow positions; use a stable item identifier as the key.
Keys define sibling identity during reconciliation. Index keys associate component state with positions, so reordering can attach state to the wrong item; stable IDs preserve identity.
That's unit 1
Answer a few questions and your score shows up here.
Nearly through. Did unit 1 of INT252 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 1 of INT252 save you a night before the exam?
Then you can help keep it free for the next batch. Ads cover part of the server bill;
the rest comes out of a student's own pocket: the domain, the storage, and keeping
the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.