
Q1
Q1 What is React primarily used for?
Building mobile apps
Server-side processing
Building user interfaces
Data analysis
Q2
Q2 Which feature of React allows it to efficiently update the UI?
Real DOM
Virtual DOM
Shadow DOM
Document Fragment
Q3
Q3 JSX stands for...
JavaScript XML
Java Syntax Extension
JavaScript Syntax
Java Structured XML
Q4
Q4 In JSX, how do you express JavaScript variables?
Inside curly braces
Inside square brackets
Inside single quotes
Inside parentheses
Q5
Q5 Which of the following is a correct way to comment in JSX?
Q6
Q6 What is the correct syntax for embedding a JavaScript expression in JSX?
Q7
Q7 JSX is processed into...
JavaScript Objects
HTML strings
Virtual DOM Nodes
Regular DOM Nodes
Q8
Q8 JSX elements must be wrapped in an enclosing tag.
What is this concept known as?
Single Child Rule
Parent-Child Relationship
React Fragment
Encapsulation
Q9
Q9 What will be displayed on the screen for the following JSX code:
2 * 5
10
2 5
25
Q10
Q10 What does the following JSX code render?
HelloWorld
Hello World
'Hello' 'World'
Hello+World
Q11
Q11 Identify the error in the following JSX:
Missing enclosing tag
Syntax error in string
Extra closing tag
No error
Q12
Q12 Identify the error in the following JSX:
Missing name attribute
Incorrect syntax for value
Nothing is wrong
Missing closing tag
Q13
Q13 What are Props in React?
Data passed from a parent component to a child component
Internal state of a component
External libraries used in React
Functions inside a component
Q14
Q14 A functional component in React is...
A class that extends React.Component
A function that returns a React element
An HTML element
A method inside a class component
Q15
Q15 Which of the following is a correct way to define a component's initial state in a class component?
Inside the render() method
Inside the constructor() method
Outside the class definition
Directly inside the class body
Q16
Q16 In React, what is the role of a key prop in a list of elements?
It helps React identify which items have changed
It defines the unique style for each item
It specifies the order of elements
It improves the performance of lists
Q17
Q17 How are state and props different in React?
State is internal and controlled by the component itself, while props are external and controlled by whatever renders the component
State and props are the same
Props are internal and state is external
State can only be used in functional components
Q18
Q18 What is the primary purpose of props in React?
To manage state within the component
To pass data and event handlers to child components
To enhance the visual styling of components
To handle form submissions
Q19
Q19 What will the following component render?
A string 'React'
A string 'MyComponent'
An error message
Nothing
Q20
Q20 Consider this code snippet:
What does MyComponent represent here?
A parent component
A child component
A prop
A state variable
Q21
Q21 Which of the following is true about React components?
They must always be written as ES6 classes
They can only return one root element
They can return multiple root elements
They cannot handle events
Q22
Q22 Identify the error in this code:
Incorrect syntax for prop1
Missing props
Extra closing tag
No error
Q23
Q23 What is the issue in this component definition?
Missing import statement for React
Incorrect props usage
Missing return statement
No issue
Q24
Q24 What does the setState() function do in a class component?
Updates the component’s state and re-renders the component
Resets the component to its initial state
Deletes the component’s state
None of the above
Q25
Q25 Which lifecycle method is called right before a component is unmounted from the DOM?
componentDidMount()
componentDidUpdate()
componentWillUnmount()
shouldComponentUpdate()
Q26
Q26 What is the correct order of lifecycle phases in a React class component?
Mounting -> Updating -> Unmounting
Updating -> Mounting -> Unmounting
Unmounting -> Mounting -> Updating
None of the above
Q27
Q27 In which lifecycle method should you make API calls in a class component?
constructor()
componentDidMount()
render()
componentDidUpdate()
Q28
Q28 What is the primary use of the componentDidUpdate method in a class component?
To render the initial UI
To perform DOM manipulations
To update the component in response to prop or state changes
To clean up resources
Q29
Q29 How does React determine whether to re-render a component in response to state changes?
It compares the current state with the previous state using a deep comparison
It re-renders every time the state changes
It uses the shouldComponentUpdate lifecycle method
None of the above
Q30
Q30 What will be the output of this code snippet?
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = { count: 1 };
} render() {
return
1
0
undefined
An error message

