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

Gyansetu Team

Leave a Comment

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

Categories
Drop us a Query
+91-9999201478

Available 24x7 for your queries

Please enable JavaScript in your browser to complete this form.