Unlimited Online Free Software Download! Get 100% Free
Hurry up!
Location: Bapunagar
Call: 800 053 0134
Email: info@hitechskillindia.in
Courses
CCC
Accounting
Software Development
Designing
Mobile Development
Digital Marketing
Specialized Courses
Live Project Training
Home
About
Placement Student's
Quiz
CCC Quiz
TallyPrime + GST Quiz
C, C++ Quiz
PHP Quiz
Laravel Quiz
React Quiz
NodeJS Quiz
Python Quiz
Java Quiz
WordPress Quiz
Digital Marketing Quiz
Front-End Quiz
Fullstack PHP Quiz
Fullstack Python Quiz
Fullstack Java Quiz
Fullstack WordPress Quiz
Fullstack NodeJS Quiz
Blog
Contact
E-Brochure
hot
Gallery
Career
We Are Hiring
Test Exam
Increase your skills
Inquiry Now
Home
About Us
Courses
CCC
Accounting
Software Development
hot
Designing
Mobile Development
new
Digital Marketing
Specialized Courses
new
Live Project Training
hot
Placement Student's
Quiz
CCC Quiz
TallyPrime + GST Quiz
C, C++ Quiz
PHP Quiz
Laravel Quiz
React Quiz
NodeJS Quiz
Python Quiz
Java Quiz
WordPress Quiz
Digital Marketing Quiz
Front-End Quiz
Fullstack PHP Quiz
Fullstack Python Quiz
Fullstack Java Quiz
Fullstack WordPress Quiz
Fullstack NodeJS Quiz
Blog
Contact Us
More
New
E-Brochure
hot
Gallery
Career
We Are Hiring
Test Exam
Increase your skills
REACT Quiz
Home
Quiz
REACT Quiz
Change Course
CCC Quiz
TallyPrime + GST Quiz
C, C++ Quiz
PHP Quiz
Laravel Quiz
React Quiz
NodeJS Quiz
Python Quiz
Java Quiz
WordPress Quiz
Digital Marketing Quiz
Front-End Quiz
Fullstack PHP Quiz
Fullstack Python Quiz
Fullstack Java Quiz
Fullstack WordPress Quiz
Fullstack NodeJS Quiz
Q.
1
What is React.js?
A.
A JavaScript framework
B.
A JavaScript library
C.
A CSS framework
D.
A backend server
Correct Answer:
B. A JavaScript library
Q.
2
Who developed React.js?
A.
Google
B.
Facebook
C.
Twitter
D.
Microsoft
Correct Answer:
B. Facebook
Q.
3
What is a React component?
A.
A function or class that optionally accepts inputs and returns a React element
B.
A CSS rule
C.
A database
D.
A type of HTTP request
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?
A.
function MyComponent() { return
Hello World
; }
B.
function MyComponent { return
Hello World
; }
C.
function MyComponent { return "Hello World"; }
D.
function MyComponent() {
Hello World
; }
Correct Answer:
A. function MyComponent() { return
Hello World
; }
Q.
5
What is JSX?
A.
A JavaScript XML
B.
A type of HTTP request
C.
A CSS preprocessor
D.
A database query language
Correct Answer:
A. A JavaScript XML
Q.
6
How do you embed JavaScript expressions in JSX?
A.
Using double quotes
B.
Using curly braces
C.
Using square brackets
D.
Using parentheses
Correct Answer:
B. Using curly braces
Q.
7
What is the purpose of render() in a React component?
A.
To define event handlers
B.
To describe what the UI should look like
C.
To make an HTTP request
D.
To update the state
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?
A.
getInitialState
B.
componentWillMount
C.
constructor
D.
render
Correct Answer:
C. constructor
Q.
9
How do you handle state in a functional component?
A.
Using this.setState
B.
Using the useState hook
C.
Using the componentWillReceiveProps method
D.
Using the state object
Correct Answer:
B. Using the useState hook
Q.
10
How can you prevent a component from rendering?
A.
Returning false from render()
B.
Returning null from render()
C.
Using shouldRender method
D.
Using this.state = false
Correct Answer:
B. Returning null from render()
Q.
11
What is a key in React and why is it important?
A.
A unique identifier used to optimize rendering
B.
A reference to the parent component
C.
A way to handle events
D.
A method to fetch data
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?
A.
componentWillUnmount
B.
componentDidUpdate
C.
componentDidMount
D.
componentWillUpdate
Correct Answer:
C. componentDidMount
Q.
13
How do you pass a method from a parent component to a child component?
A.
As a prop
B.
As a state
C.
Using this.bind
D.
Using useEffect
Correct Answer:
A. As a prop
Q.
14
Which hook is used to perform side effects in functional components?
A.
useContext
B.
useEffect
C.
useState
D.
useReducer
Correct Answer:
B. useEffect
Q.
15
Which of the following methods is used to update state in a class component?
A.
updateState
B.
setState
C.
changeState
D.
modifyState
Correct Answer:
B. setState
Q.
16
What is the purpose of the useEffect hook in React?
A.
To handle state updates
B.
To fetch data or run side effects
C.
To create a reference to a DOM element
D.
To manage component lifecycle
Correct Answer:
B. To fetch data or run side effects
Q.
17
How can you conditionally apply a class to a React element?
A.
Using if statements inside render
B.
Using ternary operators inside className
C.
Using a switch statement inside className
D.
Using setState to change the class
Correct Answer:
B. Using ternary operators inside className
Q.
18
Which method is used to remove a component from the DOM?
A.
componentDidMount
B.
componentWillUnmount
C.
componentDidUpdate
D.
componentWillReceiveProps
Correct Answer:
B. componentWillUnmount
Q.
19
What is the virtual DOM in React?
A.
A copy of the real DOM that is kept in memory and synced with the real DOM
B.
A browser API for managing elements
C.
A tool for debugging React components
D.
A feature for optimizing CSS
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?
A.
By using higher-order components
B.
By moving state to a common ancestor component
C.
By using context
D.
By using Redux
Correct Answer:
B. By moving state to a common ancestor component
Q.
21
What is a pure component in React?
A.
A component that never re-renders
B.
A component that only re-renders when its props or state change
C.
A component that handles side effects
D.
A component that is always functional
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?
A.
Mixins
B.
Render props
C.
Context
D.
All of the above
Correct Answer:
D. All of the above
Q.
23
What does ReactDOM.render() do?
A.
It updates the state of a component
B.
It compiles JSX into JavaScript
C.
It renders a React element into the DOM
D.
It creates a virtual DOM
Correct Answer:
C. It renders a React element into the DOM
Q.
24
Which React hook should you use for managing form inputs?
A.
useReducer
B.
useEffect
C.
useState
D.
useContext
Correct Answer:
C. useState
Q.
25
What is a higher-order component (HOC) in React?
A.
A component that manages state
B.
A function that takes a component and returns a new component
C.
A method to fetch data from APIs
D.
A component that uses hooks
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?
A.
Using the on prefix followed by the event name
B.
Using the addEventListener method
C.
Using inline JavaScript code
D.
Using data attributes
Correct Answer:
A. Using the on prefix followed by the event name
Q.
27
Which of the following is a controlled component in React?
A.
A component that controls its own state
B.
A component that receives its current value as a prop and notifies changes via callbacks
C.
A component that is not affected by state changes
D.
A component that uses refs to access the DOM
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?
A.
To create a wrapper element in the DOM
B.
To avoid adding extra nodes to the DOM
C.
To render multiple components conditionally
D.
To handle form submissions
Correct Answer:
B. To avoid adding extra nodes to the DOM
Q.
29
How can you memoize a component to prevent unnecessary re-renders?
A.
By using React.memo
B.
By using useEffect
C.
By using useCallback
D.
By using useState
Correct Answer:
A. By using React.memo
Q.
30
What is the use of prop-types in React?
A.
To optimize component performance
B.
To document the intended types of properties passed to components
C.
To manage state in components
D.
To create context in a React application
Correct Answer:
B. To document the intended types of properties passed to components
Q.
31
What is context in React?
A.
A way to pass data through the component tree without having to pass props down manually at every level
B.
A state management tool
C.
A method to create side effects
D.
A lifecycle method
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?
A.
It manages component side effects
B.
It allows a functional component to access context
C.
It triggers a re-render
D.
It replaces useState
Correct Answer:
B. It allows a functional component to access context
Q.
33
What is the significance of keys in lists in React?
A.
They determine the order of elements in the DOM
B.
They help identify which items have changed, are added, or removed
C.
They are used to style list items
D.
They are required to use map function
Correct Answer:
B. They help identify which items have changed, are added, or removed
Q.
34
What is a stateful component in React?
A.
A component that manages its own state
B.
A component that only receives props
C.
A component that uses hooks
D.
A component that does not re-render
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?
A.
useState
B.
useEffect
C.
useRef
D.
useReducer
Correct Answer:
C. useRef
Q.
36
How do you create a context in React?
A.
const MyContext = createContext();
B.
const MyContext = new Context();
C.
const MyContext = useContext();
D.
const MyContext = useCreateContext();
Correct Answer:
A. const MyContext = createContext();
Q.
37
What does the useReducer hook do?
A.
It manages state with a reducer function
B.
It replaces the useState hook
C.
It performs side effects in functional components
D.
It creates a context
Correct Answer:
A. It manages state with a reducer function
Q.
38
What is the purpose of React.StrictMode?
A.
To enforce strict typing
B.
To highlight potential problems in an application
C.
To manage state
D.
To optimize performance
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?
A.
this.setState
B.
this.forceUpdate
C.
this.updateState
D.
this.modifyState
Correct Answer:
A. this.setState
Q.
40
How do you access props in a class component?
A.
this.properties
B.
this.args
C.
this.state
D.
this.props
Correct Answer:
D. this.props
Q.
41
What does the shouldComponentUpdate lifecycle method do?
A.
It forces a component to update
B.
It determines if a component should re-render
C.
It is used to fetch data from an API
D.
It binds event handlers
Correct Answer:
B. It determines if a component should re-render
Q.
42
Which of the following is NOT a feature of React Router?
A.
Route nesting
B.
Code splitting
C.
Lazy loading
D.
Automatic state management
Correct Answer:
D. Automatic state management
Q.
43
What is the purpose of the useLayoutEffect hook?
A.
To perform side effects in a synchronous manner
B.
To handle state updates
C.
To replace useEffect
D.
To manage context
Correct Answer:
A. To perform side effects in a synchronous manner
Q.
44
How do you define default props for a component?
A.
Component.defaultProps = { ... }
B.
Component.props = { ... }
C.
Component.default = { ... }
D.
Component.defaultProperties = { ... }
Correct Answer:
A. Component.defaultProps = { ... }
Q.
45
What is the primary purpose of the React.Children utility?
A.
To validate child components
B.
To manage state in child components
C.
To provide utilities for dealing with the this.props.children opaque data structure
D.
To style child components
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?
A.
useEffect runs after the DOM updates, useLayoutEffect runs synchronously after all DOM mutations
B.
useLayoutEffect runs after the DOM updates, useEffect runs synchronously after all DOM mutations
C.
useEffect is used for context management, useLayoutEffect is used for state management
D.
There is no difference
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?
A.
They should be unique among sibling elements
B.
They are required for all elements in React
C.
They should be generated randomly each time the component renders
D.
They are used to store state in React
Correct Answer:
A. They should be unique among sibling elements
Q.
48
What is the purpose of the memo function in React?
A.
To memoize the results of expensive calculations
B.
To create context
C.
To prevent unnecessary re-renders of functional components
D.
To manage state
Correct Answer:
C. To prevent unnecessary re-renders of functional components
Q.
49
What does the createRef function do in React?
A.
It creates a reference to a DOM element or class component instance
B.
It manages state updates
C.
It fetches data from APIs
D.
It creates context
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?
A.
To memoize a function
B.
To memoize a value
C.
To manage state
D.
To handle side effects
Correct Answer:
B. To memoize a value
Q.
51
How can you pass multiple children to a React component?
A.
Using an array of elements
B.
Using React.Fragment or <>...>
C.
Using children prop
D.
All of the above
Correct Answer:
D. All of the above
Q.
52
What is the purpose of the ErrorBoundary component in React?
A.
To handle JavaScript errors in a part of the component tree
B.
To manage component state
C.
To perform side effects
D.
To validate props
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?
A.
useEffect
B.
useState
C.
useMemo
D.
useRef
Correct Answer:
C. useMemo
Q.
54
How do you force a component to re-render?
A.
this.setState()
B.
this.forceUpdate()
C.
this.updateComponent()
D.
this.renderAgain()
Correct Answer:
B. this.forceUpdate()
Q.
55
What is the primary use of the useRef hook in functional components?
A.
To directly manipulate the DOM.
B.
To manage state.
C.
To perform side effects.
D.
To manage props.
Correct Answer:
A. To directly manipulate the DOM.
Q.
56
Which lifecycle method is invoked just before a component is removed from the DOM?
A.
componentDidMount
B.
componentWillUnmount
C.
componentDidUpdate
D.
componentWillUpdate
Correct Answer:
B. componentWillUnmount
Q.
57
What does props.children contain?
A.
The properties passed to a component.
B.
The state of the component.
C.
The nested elements within a component.
D.
The methods of a component.
Correct Answer:
C. The nested elements within a component.
Q.
58
How can you handle forms in React?
A.
By directly manipulating the DOM.
B.
By using controlled components.
C.
By using uncontrolled components.
D.
Both b and c.
Correct Answer:
D. Both b and c.
Q.
59
What does the useImperativeHandle hook do?
A.
It customizes the instance value that is exposed when using ref in functional components.
B.
It manages state.
C.
It performs side effects.
D.
It sets up subscriptions.
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?
A.
useEffect
B.
useState
C.
useMemo
D.
useCallback
Correct Answer:
C. useMemo
Q.
61
What is the purpose of the default keyword when exporting a React component?
A.
It exports a component that can be imported with any name.
B.
It exports a component with the same name.
C.
It allows multiple components to be exported.
D.
It exports a component as a class.
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?
A.
Using useState
B.
Using useEffect
C.
Using useMemo
D.
Using useReducer
Correct Answer:
B. Using useEffect
Q.
63
What is the purpose of the key prop in React lists?
A.
To style list items.
B.
To uniquely identify elements and optimize rendering.
C.
To bind event handlers.
D.
To manage state.
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?
A.
setTimeout
B.
useTimer
C.
createTimer
D.
setInterval
Correct Answer:
A. setTimeout
Q.
65
What is the main advantage of using React.PureComponent?
A.
It ensures the component always re-renders.
B.
It optimizes the component by performing a shallow comparison of props and state.
C.
It allows the component to manage its own state.
D.
It enables the component to handle side effects.
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?
A.
Using class syntax.
B.
Using hooks like useEffect.
C.
Using this keyword.
D.
Using higher-order components.
Correct Answer:
B. Using hooks like useEffect.
Q.
67
What is the role of ReactDOM in a React application?
A.
It provides methods to manage state.
B.
It handles rendering of React components in the DOM.
C.
It manages component lifecycle.
D.
It performs side effects.
Correct Answer:
B. It handles rendering of React components in the DOM.
Q.
68
Which method is used to create an element in React?
A.
React.createElement
B.
React.makeElement
C.
React.buildElement
D.
React.generateElement
Correct Answer:
A. React.createElement
Q.
69
What does the useReducer hook return?
A.
An array containing the current state and a dispatch function.
B.
An object containing the current state and a dispatch function.
C.
A function to update the state.
D.
An array containing the current state and a state updater function.
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?
A.
Controlled components manage their own state, uncontrolled components use refs.
B.
Controlled components use refs, uncontrolled components manage their own state.
C.
Controlled components are stateless, uncontrolled components are stateful.
D.
Controlled components use props, uncontrolled components do not.
Correct Answer:
A. Controlled components manage their own state, uncontrolled components use refs.
Q.
71
What is a React Portal?
A.
A way to render children into a different part of the DOM tree.
B.
A method to manage state.
C.
A lifecycle method.
D.
A way to handle side effects.
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?
A.
Using try and catch blocks.
B.
Using ErrorBoundary components.
C.
Using componentDidCatch lifecycle method.
D.
Both b and c.
Correct Answer:
D. Both b and c.
Q.
73
How can you optimize the performance of a React application?
A.
Using keys in lists.
B.
Using React.memo.
C.
Using useMemo and useCallback.
D.
All of the above.
Correct Answer:
D. All of the above.
Q.
74
Which of the following is used to handle routing in a React application?
A.
React Route
B.
Redux
C.
Context API
D.
MobX
Correct Answer:
A. React Route
Q.
75
What does the useState hook return?
A.
The current state and a function to update it.
B.
The current state and a reducer function.
C.
A function to fetch data and a function to set data.
D.
The initial state and a function to reset it.
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?
A.
To define the type of context
B.
To set default props
C.
To consume context in a class component
D.
To manage state
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?
A.
useEffect
B.
useState
C.
useRef
D.
useReducer
Correct Answer:
A. useEffect
Q.
78
What does the useTransition hook do?
A.
It manages component transitions.
B.
It provides a way to track the completion of a state update
C.
It defers state updates to improve performance.
D.
It handles side effects.
Correct Answer:
C. It defers state updates to improve performance.
Q.
79
What is the purpose of ReactDOM.createPortal?
A.
To create a new DOM element
B.
To render children into a different part of the DOM tree
C.
To manage state
D.
To handle form submissions
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?
A.
By calling the method in the child component
B.
By using the bind method
C.
By passing it directly as a prop
D.
By using useState
Correct Answer:
C. By passing it directly as a prop
Q.
81
Which hook is used to perform a cleanup function in React?
A.
useState
B.
useReducer
C.
useEffect
D.
useCallback
Correct Answer:
C. useEffect
Q.
82
How do you ensure that a function is only recreated when its dependencies change?
A.
By using useEffect
B.
By using useMemo
C.
By using useCallback
D.
By using useState
Correct Answer:
C. By using useCallback
Q.
83
Which of the following methods can be used to create a context in React?
A.
React.createContext
B.
React.useContext
C.
React.Context
D.
React.create
Correct Answer:
A. React.createContext
Q.
84
What is the primary purpose of React.lazy?
A.
To perform side effects lazily
B.
To load components lazily for code splitting
C.
To manage state
D.
To handle routing
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?
A.
componentDidMount
B.
componentDidUpdate
C.
componentWillUnmount
D.
getSnapshotBeforeUpdate
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?
A.
React will throw an error.
B.
The last Hook call will override the previous ones.
C.
Each Hook call is independent and maintains its own state.
D.
Hooks can only be called once per 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?
A.
Use React.memo to wrap the component.
B.
Use shouldComponentUpdate to compare props and state.
C.
Use useCallback for any functions passed as context values.
D.
All of the above.
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?
A.
useEffect
B.
useLayoutEffect
C.
useReducer
D.
useCallback
Correct Answer:
D. useCallback
Q.
89
Which of the following is true about using useReducer over useState?
A.
useReducer is better suited for managing complex state logic.
B.
useReducer can only be used in class components.
C.
useReducer always improves performance over useState.
D.
useReducer requires a middleware to function.
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?
A.
componentWillMount
B.
componentDidMount
C.
componentWillUpdate
D.
componentDidUpdate
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?
A.
useEffect
B.
useErrorBoundary
C.
useError
D.
React does not currently provide a built-in hook for error handling in functional components.
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?
A.
To ensure uniqueness of elements within the list.
B.
To specify the order of elements in the list.
C.
To provide a reference to access elements within the list
D.
To determine the styling of elements in the list.
Correct Answer:
A. To ensure uniqueness of elements within the list.
Q.
93
How do you import a CSS file in a React component?
A.
import styles from './styles.css';
B.
import { styles } from './styles.css';
C.
import './styles.css';
D.
require('./styles.css');
Correct Answer:
C. import './styles.css';
Q.
94
Which of the following is true about React's reconciliation process?
A.
It always updates the entire DOM tree.
B.
It updates only the parts of the DOM that have changed.
C.
It bypasses the virtual DOM.
D.
It is performed manually by the developer.
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?
A.
To create a callback function that doesn't change unless its dependencies change.
B.
To fetch data from an API.
C.
To create a mutable reference object.
D.
To manage state.
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?
A.
It prevents the component from updating unless its props have changed.
B.
It memoizes the component's state.
C.
It keeps a reference to the component to avoid re-creation.
D.
It ensures the component is always re-rendered when its parent updates.
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?
A.
Use React.memo to wrap the component.
B.
Use PureComponent instead of a function component.
C.
Use the useEffect hook to compare props.
D.
Use the shouldComponentUpdate method.
Correct Answer:
A. Use React.memo to wrap the component.