Question#1 What feature enabled function components in React to nearly match class components in terms of state and lifecycle capabilities? a) The use of props b) The use of JSX c) The default export system d) The introduction of Hooks ✅- Answer Question#2 Before React 16.8, which type of component was primarily used for tracking state and lifecycle? a) Function components b) Class components ✅- Answer c) Stateless widgets d) Custom hooks Question#3 What is the main purpose of props in React components? a) To pass data from one component to another ✅- Answer b) To store local component state c) To define event handlers d) To import external CSS files Question#4 What is a characteristic of props in React? a) They can be modified inside the component b) They manage the component's state c) They are immutable and read-only ✅- Answer d) They must be unique for each component Question#5 How does a React functional component typically return content? a) By using a constructor method b) By updating the DOM directly c) By calling setState d) By returning a JSX definition ✅- Answer Question#6 Which React lifecycle method is used to set the initial state of a class component? a) By defining props b) By calling setState directly c) Inside the constructor with this.state ✅- Answer d) By using a render method Question#7 How are event handlers typically assigned in JSX syntax? a) Snake_case attribute with a string b) Lowercase attribute with a string c) CamelCase attribute with a function reference ✅- Answer d) Lowercase attribute with a function call Question#8 What should be used to prevent the default action for an event in React? a) Set event.default to false b) Return false from the handler c) Use stopPropagation property d) Call preventDefault explicitly in handler ✅- Answer Question#9 In the example given, which method is used to update a component's state? a) changeState() b) updateState() c) setState() ✅- Answer d) applyState() Question#10 What does the following line do: ? a) Initializes a state variable for carname b) Sets the car component's state directly c) Passes the carname variable as the brand prop to the Car component ✅- Answer d) Passes carname as a child node Question#11 What does 'this.props' allow access to inside a class component? a) Component's CSS styles b) Component's local state c) Component's event handlers d) Props passed to the component ✅- Answer Question#12 How is a React class component typically defined? a) By defining a function with return JSX b) By using the useState hook c) By extending React.Component and using a render method ✅- Answer d) By importing 'app.css' directly Question#13 What does 'this.state' store in a React class component? a) Immutable props from parent b) The DOM output of the component c) The component's current local data ✅- Answer d) Methods for handling events Question#14 What is the output of the header.js functional component example? a) functional header loaded b) header component rendered c) diploma computer /it engineering d) my first functional component ✅- Answer Question#15 Which file is typically used to render a component into the DOM in a React application? a) app.js using setState() b) cars.js with export default c) header.js directly d) main.js or index.js using ReactDOM.render() ✅- Answer Question#16 What is the correct way to define the initial state in a class component? a) Define state as a global variable b) Use props to define state values c) Assign an object to this.state in the constructor ✅- Answer d) Set state inside the render method Question#17 Which of the following is TRUE about state in React? a) State is immutable like props b) State is accessible from any component c) State is local and updatable data within a component ✅- Answer d) State is passed to components as arguments Question#18 How are dynamic values rendered using props in a class component? a) By updating this.state directly b) By passing arguments to setState c) By referencing this.props inside the render method ✅- Answer d) By using setState in the constructor Question#19 What triggers a UI update in React when using class components? a) Modifying props directly b) Changing function arguments c) Importing a CSS file d) Calling setState() with new values ✅- Answer Question#20 Why are function components generally preferred over class components in modern React? a) Class components cannot use JSX b) Function components are always faster c) Function components require less memory d) Hooks have given function components state and lifecycle features ✅- Answer