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

  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

  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

  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.

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