Full-Stack Development Full-Stack Development Frontend Frameworks & UI Architecture 1 — Questions and Answers
Question 1: Which React hook is used to perform side effects such as data fetching or subscriptions in a functional component?
- useState
- useEffect (Correct answer)
- useContext
- useReducer
Correct answer: useEffect
useEffect runs after every render by default and is used for side effects like API calls, subscriptions, and DOM mutations.
Question 2: In Vue 3, which Composition API function creates a reactive reference to a primitive value?
- reactive()
- ref() (Correct answer)
- computed()
- watch()
Correct answer: ref()
ref() wraps a primitive value in a reactive object, accessible via .value in script and auto-unwrapped in templates.
Question 3: What does the Angular CLI command `ng generate component header` do?
- Installs the Angular header package
- Creates a new component with its template, styles, spec, and module declaration (Correct answer)
- Generates a routing module for the header
- Compiles the header component for production
Correct answer: Creates a new component with its template, styles, spec, and module declaration
ng generate component creates the .ts, .html, .css, and .spec.ts files and automatically declares the component in the nearest module.
Question 4: Which tool is most commonly used to bundle JavaScript modules in modern React applications?
- Babel
- Webpack (Correct answer)
- ESLint
- Prettier
Correct answer: Webpack
Webpack is the default bundler used by Create React App, combining modules, assets, and dependencies into optimized bundles.
Question 5: What is the Virtual DOM in React?
- A DOM stored in a database
- An in-memory representation of the real DOM used to batch and optimize updates (Correct answer)
- A virtual machine that runs the DOM
- A shadow DOM implementation
Correct answer: An in-memory representation of the real DOM used to batch and optimize updates
React maintains a virtual DOM in memory, diffs it with the previous version, and only applies the minimum necessary changes to the real DOM.
Question 6: In a single-page application (SPA), what is the role of a client-side router such as React Router?
- It sends requests to multiple backend servers
- It intercepts URL changes and renders the appropriate component without a full page reload (Correct answer)
- It caches API responses in the browser
- It compiles TypeScript to JavaScript
Correct answer: It intercepts URL changes and renders the appropriate component without a full page reload
Client-side routers listen for URL changes and swap rendered components, enabling navigation without network round-trips for new HTML.
Which React hook is used to perform side effects such as data fetching or subscriptions in a functional component?