Comparison Operators

Last Updated :
Discuss
Comments

Question 1

What is the main purpose of comparison operators in MongoDB?

  • Insert data

  • Delete data

  • Compare field values

  • Create collections

Question 2

Which operator is used for equality comparison?

  • $gt

  • $lt

  • $eq

  • $cmp

Question 3

Which operator is used to find values greater than a specified value?

  • $lt

  • $gt

  • $eq

  • $cmp

Question 4

Which operator is used to find values less than a specified value?

  • $gt

  • $eq

  • $lt

  • $cmp

Question 5

What does the $cmp operator do?

  • Deletes documents

  • Compares two values

  • Inserts documents

  • Updates documents

Question 6

What will $cmp return if the first value is greater than the second?

  • -1

  • 0

  • 1

  • null

Question 7

What will $cmp return if the first value is smaller than the second?

  • -1

  • 0

  • 1

  • undefined

Question 8

Which operator would you use to match documents where age = 25?

  • {age: {$gt:25}}

  • {age: {$lt:25}}

  • {age: {$eq:25}}

  • {age: {$cmp:25}}

Question 9

Which operator is best for filtering numeric ranges?

  • $eq

  • $cmp

  • $gt and $lt

  • $set

Question 10

Where are comparison operators mainly used?

  • Database creation

  • Query filters

  • Insert operations

  • Collection deletion

There are 15 questions to complete.

Take a part in the ongoing discussion