Unlimited Online Free Software Download! Get 100% Free Hurry up!
Q. 1   What is React.js?
  • Correct Answer: B. A JavaScript library

Q. 2   Who developed React.js?
  • Correct Answer: B. Facebook

Q. 3   What is a React component?
  • Correct Answer: A. A function or class that optionally accepts inputs and returns a React element

Q. 4   How do you create a React component using a function?
  • Correct Answer: A. function MyComponent() { return
    Hello World
    ; }

Q. 5   What is JSX?
  • Correct Answer: A. A JavaScript XML

Q. 6   How do you embed JavaScript expressions in JSX?
  • Correct Answer: B. Using curly braces

Q. 7   What is the purpose of render() in a React component?
  • Correct Answer: B. To describe what the UI should look like

Q. 8   Which method in a React class component is used to set initial state?
  • Correct Answer: C. constructor

Q. 9   How do you handle state in a functional component?
  • Correct Answer: B. Using the useState hook

Q. 10   How can you prevent a component from rendering?
  • Correct Answer: B. Returning null from render()

Q. 11   What is a key in React and why is it important?
  • Correct Answer: A. A unique identifier used to optimize rendering

Q. 12   Which lifecycle method is called after the component is rendered for the first time?
  • Correct Answer: C. componentDidMount

Q. 13   How do you pass a method from a parent component to a child component?
  • Correct Answer: A. As a prop

Q. 14   Which hook is used to perform side effects in functional components?
  • Correct Answer: B. useEffect

Q. 15   Which of the following methods is used to update state in a class component?
  • Correct Answer: B. setState

Q. 16   What is the purpose of the useEffect hook in React?
  • Correct Answer: B. To fetch data or run side effects

Q. 17   How can you conditionally apply a class to a React element?
  • Correct Answer: B. Using ternary operators inside className

Q. 18   Which method is used to remove a component from the DOM?
  • Correct Answer: B. componentWillUnmount

Q. 19   What is the virtual DOM in React?
  • Correct Answer: A. A copy of the real DOM that is kept in memory and synced with the real DOM

Q. 20   How can you lift state up in React?
  • Correct Answer: B. By moving state to a common ancestor component

Q. 21   What is a pure component in React?
  • Correct Answer: B. A component that only re-renders when its props or state change

Q. 22   Which of the following can be used to share logic across React components?
  • Correct Answer: D. All of the above

Q. 23   What does ReactDOM.render() do?
  • Correct Answer: C. It renders a React element into the DOM

Q. 24   Which React hook should you use for managing form inputs?
  • Correct Answer: C. useState

Q. 25   What is a higher-order component (HOC) in React?
  • Correct Answer: B. A function that takes a component and returns a new component

Q. 26   What is the correct way to handle events in React?
  • Correct Answer: A. Using the on prefix followed by the event name

Q. 27   Which of the following is a controlled component in React?
  • Correct Answer: B. A component that receives its current value as a prop and notifies changes via callbacks

Q. 28   What is the purpose of React.Fragment?
  • Correct Answer: B. To avoid adding extra nodes to the DOM

Q. 29   How can you memoize a component to prevent unnecessary re-renders?
  • Correct Answer: A. By using React.memo

Q. 30   What is the use of prop-types in React?
  • Correct Answer: B. To document the intended types of properties passed to components

Q. 31   What is context in React?
  • Correct Answer: A. A way to pass data through the component tree without having to pass props down manually at every level

Q. 32   What does the useContext hook do?
  • Correct Answer: B. It allows a functional component to access context

Q. 33   What is the significance of keys in lists in React?
  • Correct Answer: B. They help identify which items have changed, are added, or removed

Q. 34   What is a stateful component in React?
  • Correct Answer: A. A component that manages its own state

Q. 35   Which of the following hooks is used to create a mutable object that persists for the lifetime of the component?
  • Correct Answer: C. useRef

Q. 36   How do you create a context in React?
  • Correct Answer: A. const MyContext = createContext();

Q. 37   What does the useReducer hook do?
  • Correct Answer: A. It manages state with a reducer function

Q. 38   What is the purpose of React.StrictMode?
  • Correct Answer: B. To highlight potential problems in an application

Q. 39   Which method would you use to update the state of a component after an asynchronous operation?
  • Correct Answer: A. this.setState

Q. 40   How do you access props in a class component?
  • Correct Answer: D. this.props

Q. 41   What does the shouldComponentUpdate lifecycle method do?
  • Correct Answer: B. It determines if a component should re-render

Q. 42   Which of the following is NOT a feature of React Router?
  • Correct Answer: D. Automatic state management

Q. 43   What is the purpose of the useLayoutEffect hook?
  • Correct Answer: A. To perform side effects in a synchronous manner

Q. 44   How do you define default props for a component?
  • Correct Answer: A. Component.defaultProps = { ... }

Q. 45   What is the primary purpose of the React.Children utility?
  • Correct Answer: C. To provide utilities for dealing with the this.props.children opaque data structure

Q. 46   What is the difference between useEffect and useLayoutEffect?
  • Correct Answer: A. useEffect runs after the DOM updates, useLayoutEffect runs synchronously after all DOM mutations

Q. 47   Which of the following is true about React keys?
  • Correct Answer: A. They should be unique among sibling elements

Q. 48   What is the purpose of the memo function in React?
  • Correct Answer: C. To prevent unnecessary re-renders of functional components

Q. 49   What does the createRef function do in React?
  • Correct Answer: A. It creates a reference to a DOM element or class component instance

Q. 50   What is the purpose of the useMemo hook in React?
  • Correct Answer: B. To memoize a value

Q. 51   How can you pass multiple children to a React component?
  • Correct Answer: D. All of the above

Q. 52   What is the purpose of the ErrorBoundary component in React?
  • Correct Answer: A. To handle JavaScript errors in a part of the component tree

Q. 53   Which hook is used to optimize performance by preventing re-renders in functional components?
  • Correct Answer: C. useMemo

Q. 54   How do you force a component to re-render?
  • Correct Answer: B. this.forceUpdate()

Q. 55   What is the primary use of the useRef hook in functional components?
  • Correct Answer: A. To directly manipulate the DOM.

Q. 56   Which lifecycle method is invoked just before a component is removed from the DOM?
  • Correct Answer: B. componentWillUnmount

Q. 57   What does props.children contain?
  • Correct Answer: C. The nested elements within a component.

Q. 58   How can you handle forms in React?
  • Correct Answer: D. Both b and c.

Q. 59   What does the useImperativeHandle hook do?
  • Correct Answer: A. It customizes the instance value that is exposed when using ref in functional components.

Q. 60   Which hook can be used to optimize the rendering of large lists?
  • Correct Answer: C. useMemo

Q. 61   What is the purpose of the default keyword when exporting a React component?
  • Correct Answer: A. It exports a component that can be imported with any name.

Q. 62   How do you handle side effects in React components?
  • Correct Answer: B. Using useEffect

Q. 63   What is the purpose of the key prop in React lists?
  • Correct Answer: B. To uniquely identify elements and optimize rendering.

Q. 64   Which of the following methods can be used to set up a timer in React?
  • Correct Answer: A. setTimeout

Q. 65   What is the main advantage of using React.PureComponent?
  • Correct Answer: B. It optimizes the component by performing a shallow comparison of props and state.

Q. 66   How do you access lifecycle methods in a functional component?
  • Correct Answer: B. Using hooks like useEffect.

Q. 67   What is the role of ReactDOM in a React application?
  • Correct Answer: B. It handles rendering of React components in the DOM.

Q. 68   Which method is used to create an element in React?
  • Correct Answer: A. React.createElement

Q. 69   What does the useReducer hook return?
  • Correct Answer: A. An array containing the current state and a dispatch function.

Q. 70   What is the difference between a controlled and uncontrolled component in React?
  • Correct Answer: A. Controlled components manage their own state, uncontrolled components use refs.

Q. 71   What is a React Portal?
  • Correct Answer: A. A way to render children into a different part of the DOM tree.

Q. 72   How do you handle errors in React components?
  • Correct Answer: D. Both b and c.

Q. 73   How can you optimize the performance of a React application?
  • Correct Answer: D. All of the above.

Q. 74   Which of the following is used to handle routing in a React application?
  • Correct Answer: A. React Route

Q. 75   What does the useState hook return?
  • Correct Answer: A. The current state and a function to update it.

Q. 76   What is the purpose of the contextType property in class components?
  • Correct Answer: C. To consume context in a class component

Q. 77   Which of the following hooks can be used to perform side effects in a functional component?
  • Correct Answer: A. useEffect

Q. 78   What does the useTransition hook do?
  • Correct Answer: C. It defers state updates to improve performance.

Q. 79   What is the purpose of ReactDOM.createPortal?
  • Correct Answer: B. To render children into a different part of the DOM tree

Q. 80   How do you pass a method as a prop to a child component?
  • Correct Answer: C. By passing it directly as a prop

Q. 81   Which hook is used to perform a cleanup function in React?
  • Correct Answer: C. useEffect

Q. 82   How do you ensure that a function is only recreated when its dependencies change?
  • Correct Answer: C. By using useCallback

Q. 83   Which of the following methods can be used to create a context in React?
  • Correct Answer: A. React.createContext

Q. 84   What is the primary purpose of React.lazy?
  • Correct Answer: B. To load components lazily for code splitting

Q. 85   Which of the following lifecycle methods is invoked just before a component is removed from the DOM?
  • Correct Answer: C. componentWillUnmount

Q. 86   In the context of React Hooks, what will happen if you call the same Hook multiple times in a single component?
  • Correct Answer: C. Each Hook call is independent and maintains its own state.

Q. 87   When using React Context, how can you optimize a component to avoid unnecessary re-renders when context values change?
  • Correct Answer: D. All of the above.

Q. 88   Which of the following is NOT a valid way to handle side effects in a functional component using React Hooks?
  • Correct Answer: D. useCallback

Q. 89   Which of the following is true about using useReducer over useState?
  • Correct Answer: A. useReducer is better suited for managing complex state logic.

Q. 90   Which of the following lifecycle methods is invoked immediately after a component is mounted in React?
  • Correct Answer: A. componentWillMount

Q. 91   Which hook can be used to emulate the behavior of componentDidCatch in functional components to handle errors in React?
  • Correct Answer: D. React does not currently provide a built-in hook for error handling in functional components.

Q. 92   In React, what is the primary purpose of using the key prop when rendering a list of elements?
  • Correct Answer: A. To ensure uniqueness of elements within the list.

Q. 93   How do you import a CSS file in a React component?
  • Correct Answer: C. import './styles.css';

Q. 94   Which of the following is true about React's reconciliation process?
  • Correct Answer: B. It updates only the parts of the DOM that have changed.

Q. 95   What is the purpose of the useCallback hook in React?
  • Correct Answer: A. To create a callback function that doesn't change unless its dependencies change.

Q. 96   How does the React.memo higher-order component (HOC) help improve performance?
  • Correct Answer: A. It prevents the component from updating unless its props have changed.

Q. 97   How can you prevent a function component from re-rendering in React when its props haven't changed?
  • Correct Answer: A. Use React.memo to wrap the component.