Mango DB MCQ Questions For Freshers
Here are 30 important multiple-choice questions (MCQs) on MongoDB for freshers, along with their answers:
- What is MongoDB?
- A) Relational Database Management System
- B) Document-Oriented Database
- C) Object-Oriented Database
- D) File System
Answer: B) Document-Oriented Database
- Which of the following is the default port used by MongoDB?
- A) 3306
- B) 5432
- C) 27017
- D) 8080
Answer: C) 27017
- What does BSON stand for?
- A) Binary Safe Object Notation
- B) Binary JavaScript Object Notation
- C) Binary Storage Object Notation
- D) Binary Structured Object Notation
Answer: B) Binary JavaScript Object Notation
- Which command is used to start the MongoDB server?
- A) mongod
- B) mongo
- C) startdb
- D) runmongo
Answer: A) mongod
- Which of the following is the correct command to connect to the MongoDB shell?
- A) mongo
- B) connect
- C) shell
- D) mongoconnect
Answer: A) mongo
- What is the default database in MongoDB?
- A) test
- B) admin
- C) system
- D) default
Answer: A) test
- Which of the following MongoDB commands is used to show all databases?
- A) show databases
- B) show all
- C) db.list()
- D) display databases
Answer: A) show databases
- Which of the following is the correct syntax to create a collection in MongoDB?
- A) db.createCollection(“collection_name”)
- B) db.collection(“collection_name”)
- C) db.create(“collection_name”)
- D) create(“collection_name”)
Answer: A) db.createCollection(“collection_name”)
- How does MongoDB store data?
- A) Tables
- B) Documents
- C) Rows
- D) Arrays
Answer: B) Documents
- Which operator is used in MongoDB to query documents in a collection?
- A) =
- B) LIKE
- C) $
- D) @
Answer: C) $
- What does the find() method do in MongoDB?
- A) Updates documents
- B) Inserts a document
- C) Retrieves documents
- D) Deletes documents
Answer: C) Retrieves documents
- Which of the following is used to delete a document in MongoDB?
- A) delete()
- B) remove()
- C) drop()
- D) destroy()
Answer: B) remove()
- What is the use of the insertOne() method in MongoDB?
- A) It inserts a single document into a collection.
- B) It inserts multiple documents into a collection.
- C) It updates a document.
- D) It creates a collection.
Answer: A) It inserts a single document into a collection.
- Which of the following methods is used to update a document in MongoDB?
- A) update()
- B) updateOne()
- C) modify()
- D) change()
Answer: B) updateOne()
- Which of the following is NOT a valid type of index in MongoDB?
- A) Single Field Index
- B) Compound Index
- C) Geospatial Index
- D) Time Index
Answer: D) Time Index
- What is the main advantage of using MongoDB over relational databases?
- A) Better security
- B) Flexibility with unstructured data
- C) Faster queries
- D) ACID compliance
Answer: B) Flexibility with unstructured data
- Which of the following command is used to remove a collection in MongoDB?
- A) db.collection.remove()
- B) db.dropCollection()
- C) db.deleteCollection()
- D) db.removeCollection()
Answer: B) db.dropCollection()
- Which of the following is the correct syntax to create an index on a field in MongoDB?
- A) db.collection.createIndex({field: 1})
- B) db.collection.addIndex({field: 1})
- C) db.collection.makeIndex({field: 1})
- D) db.collection.setIndex({field: 1})
Answer: A) db.collection.createIndex({field: 1})
- What type of database is MongoDB?
- A) SQL Database
- B) NoSQL Database
- C) Graph Database
- D) In-Memory Database
Answer: B) NoSQL Database
- Which method is used to get a document count in MongoDB?
- A) db.collection.count()
- B) db.collection.countDocuments()
- C) db.collection.size()
- D) db.collection.total()
Answer: B) db.collection.countDocuments()
- What is a replica set in MongoDB?
- A) A backup database
- B) A group of MongoDB servers that maintain the same data set
- C) A group of MongoDB servers that are connected in a cluster
- D) A method for caching data
Answer: B) A group of MongoDB servers that maintain the same data set
- What is sharding in MongoDB?
- A) A backup strategy
- B) A method of distributing data across multiple machines
- C) A method of joining collections
- D) A process to secure data
Answer: B) A method of distributing data across multiple machines
- Which method is used to drop a database in MongoDB?
- A) dropDatabase()
- B) deleteDatabase()
- C) removeDatabase()
- D) dropDB()
Answer: A) dropDatabase()
- What is the default write concern in MongoDB?
- A) 1
- B) 2
- C) “majority”
- D) 0
Answer: A) 1
- Which command is used to show all collections in MongoDB?
- A) show collections
- B) show all
- C) collections()
- D) db.showCollections()
Answer: A) show collections
- In MongoDB, which of the following is the correct operator for selecting values greater than a given value?
- A) >
- B) $gt
- C) $lt
- D) >=
Answer: B) $gt
- Which of the following MongoDB commands is used for a full-text search?
- A) text()
- B) search()
- C) fullText()
- D) searchText()
Answer: A) text()
- What does the aggregate() method do in MongoDB?
- A) It aggregates documents into a single document.
- B) It performs a grouping operation.
- C) It retrieves documents.
- D) It updates documents.
Answer: B) It performs a grouping operation.
- Which of the following statements is true about MongoDB?
- A) MongoDB supports ACID transactions.
- B) MongoDB does not support indexing.
- C) MongoDB is not scalable.
- D) MongoDB does not allow data replication.
Answer: A) MongoDB supports ACID transactions.
- Which of the following is NOT a valid data type in MongoDB?
- A) Integer
- B) ObjectId
- C) Float
- D) Enum
Answer: D) Enum
These questions and answers provide a solid foundation of basic MongoDB concepts for freshers.