0% found this document useful (0 votes)
118 views2 pages

React MCQ

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views2 pages

React MCQ

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Reg No: 12110601

Name:Nishtha-Khosla
Roll No:16
Setion :K21AF
MCQ
Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15
A B A A C A C C A A

1. What is an event handler in [Link]? 4. Which hook is commonly used to manage


- A) A function that handles user state in React functional components?
interactions or events - A) `useState`
- B) A built-in component for handling - B) `useEffect`
events - C) `useReducer`
- C) A method to style components based - D) `useContext`
on user actions
- D) A library for managing state in React
5. What is the purpose of the `onChange`
2. Which React attribute is used to assign event handler in React?
an event handler to a DOM element? - A) It handles changes in component
- A) `eventHandler` state.
- B) `onClick` - B) It triggers when the component is
- C) `handleEvent` rendered.
- D) `eventListener` - C) It fires when the input value changes.
- D) It listens for mouse clicks on the
3. In React, how do you define an event component.
handler for a button click event?
- A) `<button 6. In React, how do you prevent the default
onClick={[Link]}>Click behavior of an event?
Me</button>` - A) Use `[Link]()`
- B) `<button - B) Use `[Link]()`
clickHandler={[Link]}>Click - C) Use
Me</button>` `[Link]()`
- C) `<button - D) Use `[Link] = true`
handleEvent={[Link]}>Click
Me</button>` 7. Which of the following is true about
- D) `<button onClick={() => synthetic events in React?
[Link]()}>Click Me</button>` - A) They are native DOM events.
- B) They are instances of the `Event` class.
- C) They are provided by React to wrap
browser events.
- D) They can be directly used to interact
with the DOM.

8. How do you pass arguments to an event


handler in React?
- A) `<button
onClick={handleClick(arg)}>Click
Me</button>`
- B) `<button
onClick={[Link](this, arg)}>Click
Me</button>`
- C) `<button onClick={() =>
handleClick(arg)}>Click Me</button>`
- D) `<button
onClick={handleClick(arg)}>Click
Me</button>`

9. Which of the following is a correct way to


define an event handler in a class
component?
- A) `handleClick(event) { }`
- B) `const handleClick = (event) => { }`
- C) `onClick = (event) => { }`
- D) `function handleClick(event) { }`

10. What is the purpose of the `onSubmit`


event handler in a form element in React?
- A) It triggers when the form is
submitted.
- B) It handles changes in the form's input
fields.
- C) It listens for clicks on the submit
button.
- D) It prevents the form from submitting.

You might also like