Q. What does `React.StrictMode` do?

  • (A) Disables unused components
  • (B) Highlights potential problems in an application
  • (C) Automatically fixes bugs
  • (D) Prevents side effects
πŸ’¬ Discuss
βœ… Correct Answer: (B) Highlights potential problems in an application
Explanation: StrictMode is used to highlight potential issues in development mode.

Q. What is a controlled component?

  • (A) A component that controls its own rendering
  • (B) A component that manages its own state
  • (C) A component whose form input values are controlled by React
  • (D) A component that is reused
πŸ’¬ Discuss
βœ… Correct Answer: (C) A component whose form input values are controlled by React
Explanation: Controlled components have form elements whose values are tied to React state.

Q. What is the purpose of `useMemo`?

  • (A) To fetch data
  • (B) To optimize performance by memoizing values
  • (C) To watch props
  • (D) To render UI elements
πŸ’¬ Discuss
βœ… Correct Answer: (B) To optimize performance by memoizing values
Explanation: `useMemo` prevents unnecessary recalculations of values.

Q. Which is true about props in React?

  • (A) Props are immutable
  • (B) Props can only be strings
  • (C) Props change during component lifetime
  • (D) Props are optional
πŸ’¬ Discuss
βœ… Correct Answer: (A) Props are immutable
Explanation: Props are read-only and cannot be modified by the component receiving them.

Q. What is the return type of a functional component?

  • (A) String
  • (B) HTML
  • (C) JSX
  • (D) Object
πŸ’¬ Discuss
βœ… Correct Answer: (C) JSX
Explanation: Functional components return JSX, which React converts to real DOM elements.

Q. How does React achieve better performance?

  • (A) By using AJAX
  • (B) By caching the DOM
  • (C) By using the virtual DOM and efficient diffing
  • (D) By using CSS-in-JS
πŸ’¬ Discuss
βœ… Correct Answer: (C) By using the virtual DOM and efficient diffing
Explanation: React uses a virtual DOM and diffing algorithm to minimize DOM updates.

Q. What happens if you try to render an array in JSX?

  • (A) It throws an error
  • (B) Only the first element renders
  • (C) All elements render correctly
  • (D) It ignores the array
πŸ’¬ Discuss
βœ… Correct Answer: (C) All elements render correctly
Explanation: JSX can render arrays of elements as long as each has a unique key.

Q. What does `defaultValue` do in input elements?

  • (A) It sets a static initial value
  • (B) It changes the state
  • (C) It disables the input
  • (D) It binds the input to state
πŸ’¬ Discuss
βœ… Correct Answer: (A) It sets a static initial value
Explanation: `defaultValue` sets the initial value for uncontrolled components.

Q. What does JSX stand for in React?

  • (A) JavaScript and XML
  • (B) Java Syntax Extension
  • (C) JavaScript XML Structure
  • (D) JavaScript eXtension
πŸ’¬ Discuss
βœ… Correct Answer: (A) JavaScript and XML
Explanation: JSX stands for JavaScript and XML, allowing HTML to be written inside JavaScript.

Q. Which of the following is not a valid React hook?

  • (A) useReducer
  • (B) useState
  • (C) useClass
  • (D) useEffect
πŸ’¬ Discuss
βœ… Correct Answer: (C) useClass
Explanation: useClass is not a valid React hook.