Practice these MCQs to sharpen your MERN Stack development skills and prepare confidently for job interviews or certification exams.
Whether you’re aiming to crack full-stack developer roles or mastering MongoDB, Express.js, React, and Node.js for your next big project ā you’re in the right place.
Get access to 60+ MERN Stack MCQs covering everything from REST APIs, React components, state management, backend logic, database queries, and deployment strategies ā all with detailed answers to reinforce your understanding. No guesswork. Just solid prep.
šµ 1ā15: MongoDB
- Which command inserts a document into a collection named users?
A. db.users.add({name: “Amit”})Ā
B. db.users.push({name: “Amit”})Ā
C. db.users.insertOne({name: “Amit”})Ā
D. db.insert.users({name: “Amit”})
ā
Answer: C
š§ insertOne() adds a single document to the collection.
- Which of these is used to find documents where age is greater than 25?
A. db.users.find({age: {$gt: 25}})Ā
B. db.users.find({age: > 25})Ā
C. db.users.where(age > 25)Ā
D. db.users.get({age: 25})
ā
Answer: A
š§ $gt is MongoDB’s greater-than operator.
- MongoDB stores data in:
A. Rows
B. Arrays
C. BSON Documents
D. Tables
ā Answer: C
š§ MongoDB stores documents in BSON (Binary JSON). - What does the drop() method do?
A. Deletes a field
B. Removes a document
C. Deletes a collection
D. Deletes the database
ā Answer: C
š§ drop() removes the entire collection. - Which operator matches any of the values specified in an array?
A. $in
B. $or
C. $set
D. $match
ā Answer: A
š§ $in checks if a fieldās value matches any value in a given array. - Which command shows all databases?
A. show dbs
B. show databases
C. list dbs
D. db.list()
ā Answer: A - Which method removes a single document?
A. delete()
B. remove()
C. deleteOne()
D. drop()
ā Answer: C - How do you update the name field to ‘John’?
db.users.updateOne({id: 1}, {$set: {name: "John"}})
A. Correct
B. Incorrect
ā
Answer: A
Become a Full-Stack Pro ā One Line of Code at a Time
- Which method returns a cursor in MongoDB?
A. find()
B. insertOne()
C. drop()
D. deleteMany()
ā Answer: A - Which command removes all documents?
A. deleteAll()
B. removeAll()
C. deleteMany({})
D. clear()
ā Answer: C - Which index type ensures field uniqueness?
A. Default
B. Compound
C. Unique
D. Text
ā Answer: C - MongoDB is a:
A. Relational DB
B. Document-oriented DB
C. Graph DB
D. Column DB
ā Answer: B - Which is true about ObjectId?
A. String
B. Timestamp + machine ID + counter
C. Random number
D. UUID
ā Answer: B - Which method sorts query results?
A. sort()
B. orderBy()
C. arrange()
D. sequence()
ā Answer: A - Which method limits the number of documents returned?
A. slice()
B. trim()
C. limit()
D. max()
ā Answer: C
š 16ā30: Express.js
- What is Express.js?
A. Frontend library
B. MongoDB tool
C. Web application framework
D. Operating system
ā Answer: C - Which method defines a GET route?
A. app.get(‘/path’, callback)Ā
B. app.route(‘/path’)Ā
C. app.GET(‘/path’, callback)Ā
D. route.get(callback)
ā
Answer: A
- What is req.params used for?
A. Query parameters
B. Route parameters
C. Headers
D. Cookies
ā Answer: B - How to send JSON response?
A. res.sendText(data)Ā
B. res.sendJSON(data)Ā
C. res.json(data)Ā
D. res.send(data, ‘application/json’)
ā
Answer: C
- What is middleware?
A. Component
B. DB connection
C. Function that runs before route
D. Template
ā Answer: C - Which port is used by default in Express apps?
A. 5000
B. 80
C. 3000
D. 27017
ā Answer: C - How to import Express?
const express = require('express')
A. Correct
ā
Answer: A
- How to handle errors in middleware?
A. next()
B. catch()
C. next(err)
D. res.end()
ā Answer: C - Which is true about express.static()?
A. Sends HTML
B. Serves static files
C. Parses cookies
D. Creates API routes
ā Answer: B - What does res.status(404).send() do?
A. Sends error page
B. Sends success
C. Sends redirect
D. Logs the request
ā Answer: A - What does body-parser middleware do?
A. Parses request body
ā Answer: A - Which route handles POST request?
app.post('/submit', callback)
ā Answer: A
- What is req.query used for?
A. POST data
B. Route params
C. Query string
D. Headers
ā Answer: C - What does next() do in middleware?
A. Ends request
B. Moves to next middleware
ā Answer: B - Which method handles 404 errors?
A. app.use() at the end
ā Answer: A
šµ 31ā45: React.js
- React is a:
A. MVC framework
B. Library for UI
ā Answer: B - How do you create a component?
function Hello() { return <h1>Hello</h1> }
ā Answer: A
- Which hook is used for state?
A. useEffect()
B. useRef()
C. useState()
ā Answer: C - JSX stands for:
A. JavaScript XML
ā Answer: A - What is the purpose of key in lists?
A. Track changes
ā Answer: A - ReactDOM renders to:
A. Backend
B. Virtual DOM
C. Real DOM
ā Answer: C - Which method is used to handle side effects?
A. useEffect()
ā Answer: A - Which is NOT a React hook?
A. useData()
ā Answer: A - State updates in React are:
A. Synchronous
B. Asynchronous
ā Answer: B - Which of these is correct conditional rendering?
{isLoggedIn ? <Dashboard /> : <Login />}
- Props are:
A. Mutable
B. Immutable
ā Answer: B - How to handle form input?
A. onInput
B. onChange with useState()
ā Answer: B - React uses which programming model?
A. Declarative
ā Answer: A - Which method creates a React app?
A. npx create-react-app
ā Answer: A - React component names must start with:
A. Lowercase
B. Uppercase
ā Answer: B
š¢ 46ā60: Node.js
- Node.js is:
A. Browser-based
B. Server-side runtime
ā Answer: B - Which method reads files in Node.js?
A. fs.read()
B. fs.readFile()
ā Answer: B - How to import built-in modules?
const fs = require('fs')
ā Answer: A
- Which module runs an HTTP server?
A. net
B. http
ā Answer: B - Which file is Node entry point?
A. server.html
B. index.js
ā Answer: B - How to handle async operations?
A. Callbacks
B. Promises
C. Async/await
D. All of the above
ā Answer: D - Which method runs a server on a port?
server.listen(3000)
ā Answer: A
Turn Ideas into Apps ā Learn Full Stack Today
- Which event is fired on data received?
A. data
ā Answer: A - How to install modules in Node?
A. node install
B. npm install
ā Answer: B - What is package.json?
A. JS file
B. Config file
ā Answer: B - What is process in Node.js?
A. Browser object
B. Global object
ā Answer: B - Which method exits a process?
A. exit()
B. process.exit()
ā Answer: B - What is REPL in Node.js?
A. Testing tool
B. Terminal shell
ā Answer: B - How to export a function in Node.js?
module.exports = myFunction
ā Answer: A
- Node.js is single-threaded but:
A. Blocks I/O
B. Uses event loop
ā Answer: B
Mastering these MERN Stack MCQs is a valuable step toward becoming a proficient full-stack developer and strengthening your web development expertise.
If you’re ready to elevate your career with hands-on projects and expert-led training, join our MERN Stack Development course in Gurgaon at Gyansetu and become industry-ready with confidence.