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
Master Frontend to Backend with Real-World Projects
- 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.