60 MERN Stack Objective Type Quiz & MCQs with Answers for Interview Preparation | Gyansetu

Gyansetu Team Data Science
MERN Stack

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

  1. 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.

  1. 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.

  1. MongoDB stores data in:
    A. Rows
    B. Arrays
    C. BSON Documents
    D. Tables
    āœ… Answer: C
    🧠 MongoDB stores documents in BSON (Binary JSON).
  2. 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.
  3. 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.
  4. Which command shows all databases?
    A. show dbs
    B. show databases
    C. list dbs
    D. db.list()
    āœ… Answer: A
  5. Which method removes a single document?
    A. delete()
    B. remove()
    C. deleteOne()
    D. drop()
    āœ… Answer: C
  6. How do you update the name field to ‘John’?
db.users.updateOne({id: 1}, {$set: {name: "John"}})

A. Correct
B. Incorrect
āœ… Answer: A

.NET MVC course

Become a Full-Stack Pro — One Line of Code at a Time

  1. Which method returns a cursor in MongoDB?
    A. find()
    B. insertOne()
    C. drop()
    D. deleteMany()
    āœ… Answer: A
  2. Which command removes all documents?
    A. deleteAll()
    B. removeAll()
    C. deleteMany({})
    D. clear()
    āœ… Answer: C
  3. Which index type ensures field uniqueness?
    A. Default
    B. Compound
    C. Unique
    D. Text
    āœ… Answer: C
  4. MongoDB is a:
    A. Relational DB
    B. Document-oriented DB
    C. Graph DB
    D. Column DB
    āœ… Answer: B
  5. Which is true about ObjectId?
    A. String
    B. Timestamp + machine ID + counter
    C. Random number
    D. UUID
    āœ… Answer: B
  6. Which method sorts query results?
    A. sort()
    B. orderBy()
    C. arrange()
    D. sequence()
    āœ… Answer: A
  7. Which method limits the number of documents returned?
    A. slice()
    B. trim()
    C. limit()
    D. max()
    āœ… Answer: C

🟠 16–30: Express.js

  1. What is Express.js?
    A. Frontend library
    B. MongoDB tool
    C. Web application framework
    D. Operating system
    āœ… Answer: C
  2. 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

  1. What is req.params used for?
    A. Query parameters
    B. Route parameters
    C. Headers
    D. Cookies
    āœ… Answer: B
  2. 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

  1. What is middleware?
    A. Component
    B. DB connection
    C. Function that runs before route
    D. Template
    āœ… Answer: C
  2. Which port is used by default in Express apps?
    A. 5000
    B. 80
    C. 3000
    D. 27017
    āœ… Answer: C
  3. How to import Express?
const express = require('express')

A. Correct
āœ… Answer: A

  1. How to handle errors in middleware?
    A. next()
    B. catch()
    C. next(err)
    D. res.end()
    āœ… Answer: C
  2. Which is true about express.static()?
    A. Sends HTML
    B. Serves static files
    C. Parses cookies
    D. Creates API routes
    āœ… Answer: B
  3. What does res.status(404).send() do?
    A. Sends error page
    B. Sends success
    C. Sends redirect
    D. Logs the request
    āœ… Answer: A
  4. What does body-parser middleware do?
    A. Parses request body
    āœ… Answer: A
  5. Which route handles POST request?
app.post('/submit', callback)

āœ… Answer: A

.NET MVC course

Master Frontend to Backend with Real-World Projects

  1. What is req.query used for?
    A. POST data
    B. Route params
    C. Query string
    D. Headers
    āœ… Answer: C
  2. What does next() do in middleware?
    A. Ends request
    B. Moves to next middleware
    āœ… Answer: B
  3. Which method handles 404 errors?
    A. app.use() at the end
    āœ… Answer: A

šŸ”µ 31–45: React.js

  1. React is a:
    A. MVC framework
    B. Library for UI
    āœ… Answer: B
  2. How do you create a component?
function Hello() { return <h1>Hello</h1> }

āœ… Answer: A

  1. Which hook is used for state?
    A. useEffect()
    B. useRef()
    C. useState()
    āœ… Answer: C
  2. JSX stands for:
    A. JavaScript XML
    āœ… Answer: A
  3. What is the purpose of key in lists?
    A. Track changes
    āœ… Answer: A
  4. ReactDOM renders to:
    A. Backend
    B. Virtual DOM
    C. Real DOM
    āœ… Answer: C
  5. Which method is used to handle side effects?
    A. useEffect()
    āœ… Answer: A
  6. Which is NOT a React hook?
    A. useData()
    āœ… Answer: A
  7. State updates in React are:
    A. Synchronous
    B. Asynchronous
    āœ… Answer: B
  8. Which of these is correct conditional rendering?
{isLoggedIn ? <Dashboard /> : <Login />}
āœ… Answer: A

  1. Props are:
    A. Mutable
    B. Immutable
    āœ… Answer: B
  2. How to handle form input?
    A. onInput
    B. onChange with useState()
    āœ… Answer: B
  3. React uses which programming model?
    A. Declarative
    āœ… Answer: A
  4. Which method creates a React app?
    A. npx create-react-app
    āœ… Answer: A
  5. React component names must start with:
    A. Lowercase
    B. Uppercase
    āœ… Answer: B

🟢 46–60: Node.js

  1. Node.js is:
    A. Browser-based
    B. Server-side runtime
    āœ… Answer: B
  2. Which method reads files in Node.js?
    A. fs.read()
    B. fs.readFile()
    āœ… Answer: B
  3. How to import built-in modules?
const fs = require('fs')

āœ… Answer: A

  1. Which module runs an HTTP server?
    A. net
    B. http
    āœ… Answer: B
  2. Which file is Node entry point?
    A. server.html
    B. index.js
    āœ… Answer: B
  3. How to handle async operations?
    A. Callbacks
    B. Promises
    C. Async/await
    D. All of the above
    āœ… Answer: D
  4. Which method runs a server on a port?

server.listen(3000)

āœ… Answer: A

.NET MVC course

Turn Ideas into Apps – Learn Full Stack Today

  1. Which event is fired on data received?
    A. data
    āœ… Answer: A
  2. How to install modules in Node?
    A. node install
    B. npm install
    āœ… Answer: B
  3. What is package.json?
    A. JS file
    B. Config file
    āœ… Answer: B
  4. What is process in Node.js?
    A. Browser object
    B. Global object
    āœ… Answer: B
  5. Which method exits a process?
    A. exit()
    B. process.exit()
    āœ… Answer: B
  6. What is REPL in Node.js?
    A. Testing tool
    B. Terminal shell
    āœ… Answer: B
  7. How to export a function in Node.js?

module.exports = myFunction

āœ… Answer: A

  1. 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.

.NET MVC course

All-in-One Developer Training for the Digital Future

AUTHOR
Gyansetu Team
Gyansetu offers top professional training certification courses designed to enhance your skills and advance your career, providing industry-relevant knowledge and practical expertise.

Leave a Comment

Your email address will not be published. Required fields are marked *

Drop us a Query
+91-9999201478

Available 24x7 for your queries

Please enable JavaScript in your browser to complete this form.
Categories