Rust MCQs with answers Page - 10

Here, you will find a collection of MCQ questions on Rust. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 833.24K Points
Coach

Q. What does `.map()` do on an Option type?

  • (A) Converts Option into Result
  • (B) Applies a function to the value if it is Some
  • (C) Clones the value
  • (D) Returns the same Option

A

Admin • 833.24K Points
Coach

Q. Which method can be used to combine two iterators in Rust?

  • (A) join()
  • (B) merge()
  • (C) zip()
  • (D) group()

A

Admin • 833.24K Points
Coach

Q. Which keyword is used to break from a loop in Rust?

  • (A) stop
  • (B) break
  • (C) exit
  • (D) return

A

Admin • 833.24K Points
Coach

Q. What will `None.unwrap()` do?

  • (A) Return None
  • (B) Return an error code
  • (C) Panic at runtime
  • (D) Convert to zero

A

Admin • 833.24K Points
Coach

Q. What is the return type of `async fn` in Rust?

  • (A) Future
  • (B) Thread
  • (C) Option
  • (D) Result

A

Admin • 833.24K Points
Coach

Q. Which type allows interior mutability in Rust?

  • (A) Box<T>
  • (B) RefCell<T>
  • (C) Rc<T>
  • (D) Option<T>

A

Admin • 833.24K Points
Coach

Q. Which standard trait allows you to compare two values for equality?

  • (A) Ord
  • (B) Eq
  • (C) PartialEq
  • (D) Compare

A

Admin • 833.24K Points
Coach

Q. What does the `drop` function do in Rust?

  • (A) Deletes the variable
  • (B) Forces the value to be dropped (deallocated) immediately
  • (C) Increments the reference count
  • (D) Freezes the variable

A

Admin • 833.24K Points
Coach

Q. Which type is used to share mutable state across threads?

  • (A) Box<T>
  • (B) Rc<T>
  • (C) Arc<Mutex<T>>
  • (D) RefCell<T>

A

Admin • 833.24K Points
Coach

Q. Which macro is used to define unit tests in Rust?

  • (A) unit!
  • (B) check!
  • (C) test!
  • (D) #[test]

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ