📘 React Basics (1–20) 8.
Which hook is used for side effects in
React?
1. What is React?
A) useEffect
A) A database
B) useSideEffect
B) A backend framework
C) useLayoutEffect
C) A JavaScript library for building UIs
D) useEvent
D) A CSS preprocessor
9. What is the default port for running React
2. Who developed React?
app?
A) Google
A) 8000
B) Microsoft
B) 3000
C) Facebook
C) 5000
D) Twitter
D) 8080
3. What is JSX?
10. How do you pass data from parent to child
A) A templating engine
in React?
B) An XML parser
A) State
C) JavaScript syntax extension
B) Events
D) A CSS framework
C) Props
4. Which command creates a new React app? D) Context
A) npm install react
11. What is the virtual DOM?
B) create-react-app myApp
A) A copy of the real DOM
C) react init
B) A minimized DOM
D) npx create-react-app myApp
C) A virtual machine
5. What does a React component return? D) A browser API
A) JSX
12. Which attribute is used in React instead of
B) HTML
class?
C) CSS
A) css
D) DOM
B) className
6. Which of the following is a functional C) styleClass
component? D) class-style
A) function Welcome() { return
13. What is a key prop used for in lists?
<h1>Hello</h1>; }
A) For accessibility
B) class Welcome extends React.Component
B) For performance optimization
{}
C) To define styles
C) React.createComponent()
D) To make HTTP requests
D) new React.Component()
14. Which method is used to render a React
7. What is the purpose of useState hook?
element?
A) To define routes
A) React.mount()
B) To send API requests
B) ReactDOM.render()
C) To manage state in functional
C) render()
components
D) React.attach()
D) To handle lifecycle events
15. What does CRA stand for? C) Only in class components
A) Create React Application D) Only with useState
B) Create React App
23. What does useState return?
C) Custom React App
A) A variable and a function
D) Component React App
B) Only a value
16. What does useEffect(() => {}, []) do? C) Only a function
A) Runs on every render D) An object
B) Runs only on mount
24. Where should state be stored in React?
C) Runs on unmount only
A) In props
D) Causes error
B) In the parent component
17. React is primarily used for building: C) Inside the component that owns it
A) Mobile apps D) In the DOM
B) Server applications
25. What is state in React?
C) User interfaces
A) External configuration
D) Databases
B) Global variables
18. Which company maintains React? C) Data maintained by the component
A) Google D) Component method
B) Amazon
26. How can you lift state up in React?
C) Facebook
A) Use Redux
D) Microsoft
B) Use useContext
19. React uses a ____ to increase performance. C) Move state to the closest common
A) Real DOM ancestor
B) Shadow DOM D) Use props
C) Virtual DOM
27. How do you initialize state in a functional
D) Local Storage
component?
20. Which lifecycle method is called after a A) this.state = {}
component is rendered? B) useState({})
A) componentWillMount() C) setState({})
B) componentDidMount() D) React.useEffect()
C) render()
28. Props are:
D) shouldComponentUpdate()
A) Immutable
🔄 Props & State (21–40) B) Mutable
C) Functions
21. What are props in React?
D) Undefined
A) Internal component variables
B) Methods in React 29. How do you pass multiple values using
C) Properties passed to components props?
D) Lifecycle methods A) Using a JSON file
B) Using a single string
22. Can props be changed inside a child
C) By passing an object
component?
D) You can't
A) Yes
B) No
30. Which hook is best for managing form field 37. What happens if you forget to set a key
values? prop in a list?
A) useRef A) React will crash
B) useReducer B) React will use indexes
C) useMemo C) Nothing
D) useState D) List won't render
31. How can you update state in a class 38. Which of the following can hold both state
component? and props?
A) Directly change it A) Functional components
B) this.setState() B) Only class components
C) useState() C) JSX
D) React.setState() D) Hooks
32. In which component type can we use 39. Can you pass functions as props?
hooks like useState? A) No
A) Class B) Yes
B) Both C) Only in class components
C) Functional D) Only globally
D) Stateless
40. Props drilling refers to:
33. What happens when state changes? A) Using multiple props
A) Nothing B) Passing props from parent to deeply
B) Component is destroyed nested child
C) Component re-renders C) Converting props to state
D) Component is cached D) Avoiding props
34. What’s the correct way to pass a prop 41. 🧠 Hooks Deep Dive (41–60)
named title to a component?
41. Which hook allows you to perform side
A) <Component :title="text" />
effects in a component?
B) <Component {title} />
A) useRef
C) <Component title="text" />
B) useState
D) <Component title:text />
C) useEffect
D) useMemo
35. Which is used to update a specific key in 42. When is useEffect called with no
state? dependency array?
A) this.updateState() A) Only on mount
B) Object.assign() B) On unmount
C) Spread operator with setState() C) On every render
D) state.update() D) Never
36. How do you use default props in a
component?
43. What does useRef return?
A) defaultProps
A) DOM node
B) default keyword
B) Object with a .current property
C) setDefault()
C) Mutable string
D) static defaultProps()
D) State setter 47. Which hook allows you to track previous
props or state values?
A) useEffect
44. Which hook should be used to memoize a B) useMemo
value? C) useCallback
A) useCallback D) useRef
B) useEffect
C) useMemo
D) useRef 48. What is the return value of useState()?
A) State object
45. Which hook memoizes a callback function?
B) Array of [state, setState]
A) useCallback
C) Single function
B) useEffect
D) JSX
C) useMemo
D) useRef 49. Can multiple hooks be used in a single
component?
46. What does the second parameter of
A) Yes
useEffect do?
B) No
A) Determines the cleanup function
C) Only two
B) Specifies how long effect should last
D) Only one per component
C) Defines when the effect should re-run
D) Initializes state
50. Which hook is used to initialize a
component's internal state?
A) useEffect
B) useMemo
C) useState
D) useRef