0% found this document useful (0 votes)
26 views6 pages

MCQ React Node

The document contains multiple-choice questions (MCQs) covering various technologies including React, Node.js, MySQL, Sequelize, Express, Axios, CORS, and React Router. Each question tests knowledge on specific concepts, hooks, methods, and best practices within these frameworks. The correct answers are indicated with a checkmark for each question.

Uploaded by

Kashish Dua
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)
26 views6 pages

MCQ React Node

The document contains multiple-choice questions (MCQs) covering various technologies including React, Node.js, MySQL, Sequelize, Express, Axios, CORS, and React Router. Each question tests knowledge on specific concepts, hooks, methods, and best practices within these frameworks. The correct answers are indicated with a checkmark for each question.

Uploaded by

Kashish Dua
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
You are on page 1/ 6

MCQ Questions (React + Node.

js + MySQL + Sequelize + Express + Axios +


CORS + React Router)
1. In React, which hook is used to manage component-level state?

 A) useEffect
 B) useState ✅
 C) useContext
 D) useReducer

2. What is the default behavior of `useEffect` without a dependency array?

 A) Runs only once


 B) Runs on every render ✅
 C) Runs only on unmount
 D) Never runs

3. In JSX, how do you handle events?

 A) Using lowercase attributes


 B) Using camelCase attributes ✅
 C) Using double quotes
 D) Using inline HTML events

4. Which of the following is valid JSX?

 A) <div class="box"></div>
 B) <div className="box"></div> ✅
 C) <div class="box"/>
 D) <div class:box></div>

5. What does `React.Fragment` help with?

 A) Styling components
 B) Returning multiple elements without extra DOM nodes ✅
 C) Fetching data
 D) Managing state

6. Which package is used for routing in React?

 A) react-navigation
 B) react-router-dom ✅
 C) router-react
 D) react-dom-router

7. Which component is used to define different routes in React Router v6?


 A) Switch
 B) Routes ✅
 C) RouteSwitch
 D) RouterSwitch

8. To navigate programmatically in React Router v6, which hook is used?

 A) useParams
 B) useHistory
 C) useNavigate ✅
 D) useRoute

9. What is the correct way to define a route in React Router v6?

 A) <Route path="/" component={Home}/>


 B) <Route exact path="/" element={<Home/>}/> ✅
 C) <Route exact path="/" render={<Home/>}/>
 D) <Route route="/" page={<Home/>}/>

10. Which hook is used to extract dynamic parameters from a route?

 A) useLocation
 B) useParams ✅
 C) useHistory
 D) useQuery

11. Axios is mainly used for?

 A) DOM Manipulation
 B) Making HTTP requests ✅
 C) State management
 D) File uploads only

12. What is the default HTTP method if not specified in Axios?

 A) GET ✅
 B) POST
 C) PUT
 D) DELETE

13. Which syntax is correct for GET request using Axios?

 A) axios.fetch('/api')
 B) axios.get('/api') ✅
 C) axios.request('/api')
 D) axios.api('/api')

14. Where is JWT usually stored in frontend for Axios authentication?


 A) sessionStorage / localStorage ✅
 B) Redux only
 C) In HTML meta tags
 D) In Cookies always

15. Axios interceptors are used to:

 A) Modify requests/responses globally ✅


 B) Change React state
 C) Render components
 D) Optimize React hooks

16. What is the default port for Express apps if not defined?

 A) 3000 ✅
 B) 4000
 C) 8080
 D) 5000

17. Which method creates an Express application?

 A) express() ✅
 B) createExpressApp()
 C) new Express()
 D) express.init()

18. Which function in Express defines middleware?

 A) app.listen()
 B) app.use() ✅
 C) app.set()
 D) app.get()

19. Which object in Express holds query parameters?

 A) req.params
 B) req.body
 C) req.query ✅
 D) req.input

20. In Express, app.listen(4000) does what?

 A) Stops server
 B) Starts server on port 4000 ✅
 C) Registers routes
 D) Adds middleware

21. Sequelize is used for?


 A) Authentication
 B) ORM for SQL databases ✅
 C) File handling
 D) API routing

22. Which method connects Sequelize to DB?

 A) sequelize.authenticate() ✅
 B) sequelize.start()
 C) sequelize.connectDB()
 D) sequelize.run()

23. In Sequelize, User.findAll() does what?

 A) Finds one row


 B) Finds all rows ✅
 C) Deletes all rows
 D) Updates rows

24. Which Sequelize datatype is used for auto-increment primary key?

 A) Sequelize.UUID
 B) Sequelize.INTEGER ✅
 C) Sequelize.STRING
 D) Sequelize.AUTO

25. Which Sequelize method is used for inserting new data?

 A) insert()
 B) save()
 C) create() ✅
 D) add()

26. What does CORS stand for?

 A) Cross-Origin Resource Sharing ✅


 B) Cross-Origin Request Service
 C) Common-Origin Resource Setup
 D) Client-Origin Routing System

27. CORS issue happens when?

 A) Same domain request


 B) Requesting resources from a different origin ✅
 C) Database error
 D) Invalid JSON

28. In Express, which package is used to handle CORS?


 A) express-cors
 B) cors ✅
 C) axios-cors
 D) node-cors

29. To allow all origins in CORS, what should be set?

 A) origin: '*' ✅
 B) origin: 'localhost'
 C) origin: 'null'
 D) origin: 'self'

30. Which HTTP header is related to CORS?

 A) Content-Type
 B) Access-Control-Allow-Origin ✅
 C) Authorization
 D) Accept-Language

31. useEffect(() => {}, []) runs:

 A) On every render
 B) Only once after first render ✅
 C) On unmount
 D) Never

32. In React, how to prevent default event behavior?

 A) event.cancel()
 B) event.preventDefault() ✅
 C) event.stop()
 D) event.halt()

33. Which hook is used for managing side effects like fetching data?

 A) useContext
 B) useReducer
 C) useEffect ✅
 D) useState

34. Which is correct syntax for updating state?

 A) count = count + 1
 B) setCount(count + 1) ✅
 C) count++
 D) updateCount(count++)

35. When updating state based on previous state, which form should be used?
 A) setState(newState)
 B) setState(prev => prev + 1) ✅
 C) setState(count++)
 D) setState(count + 1, prev)

36. What is the correct sequence for frontend-backend DB flow?

 A) React → Node/Express → MySQL ✅


 B) MySQL → React → Node
 C) Express → React → Sequelize
 D) React → Sequelize → Node

37. Which HTTP method is used for updating existing data?

 A) GET
 B) POST
 C) PUT ✅
 D) DELETE

38. Which hook is best for calling API when a component loads?

 A) useState
 B) useEffect ✅
 C) useMemo
 D) useContext

39. JWT tokens are usually sent in:

 A) Response body only


 B) Authorization header ✅
 C) Cookies always
 D) Local file

40. In React + Node project, where is proxy usually defined for API calls?

 A) In Express app.js
 B) In React package.json ✅
 C) In Sequelize config
 D) In Axios interceptor only

You might also like