Question 1
How does React update the UI when a state change occurs?
It reloads the whole page
It re-renders the components affected by the state change
It triggers a complete re-render of the application
It does not update the UI on state change
Question 2
During reconciliation, how does React decide if a component should be updated, replaced, or left unchanged?
By comparing props only
By checking the component's state
By comparing old and new virtual DOM using keys and element types
By using the real DOM
Question 3
What happens if you try to return multiple JSX elements without a parent wrapper?
React wraps them in a div
Compilation error
Only the last element renders
React ignores extra elements
Question 4
What happens when you call this.setState() in React?
The component is immediately re-rendered
React schedules an update to the component’s state
It only updates the virtual DOM
It reloads the whole application
Question 5
Which of the following JSX expressions is valid?
<button disabled={false && "true"}>Click me</button>
<button disabled={false && true}>Click me</button>
<button disabled={true && "false"}>Click me</button>
<button disabled={"false && true"}>Click me</button>
Question 6
Why should you use stable key values in lists during reconciliation?
To improve SEO
To allow CSS styling
To avoid unnecessary re-renders and DOM manipulations
To enable default props
Question 7
How does React’s reconciliation process minimize the number of renders?
By using state only when absolutely necessary
By updating only the parts of the DOM that have changed
By delaying all state changes until after rendering
By not allowing multiple state changes in one render cycle
Question 8
Which of the following scenarios will trigger a re-render in React?
const App = () => {
const [count, setCount] = React.useState(0);
const handleClick = () => setCount(count + 1);
return (
<div>
<button onClick={handleClick}>Increment</button>
<p>{count}</p>
</div>
);
};
When the state count changes.
When the setCount function is called.
Both when the state changes and when setCount is called.
Only when setCount is called.
Question 9
What does the Virtual DOM do when a state changes?
It updates the real DOM directly
It creates a new tree and compares it to the old one
It triggers a re-render of all components
It never triggers any DOM changes
Question 10
What will be the output of the following React code snippet?
const MyComponent = () => {
const [count, setCount] = React.useState(0);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
};
A button that increments count every time it is clicked
A static button showing count as 0
A button that displays "undefined"
The button will never render
There are 10 questions to complete.