Rust MCQs with answers Page - 9

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 • 832.27K Points
Coach

Q. Which keyword is used to define a trait implementation for a struct in Rust?

  • (A) interface
  • (B) impl
  • (C) trait
  • (D) struct

A

Admin • 832.27K Points
Coach

Q. Which keyword is used to define a generic function in Rust?

  • (A) generic
  • (B) fn<T>
  • (C) template
  • (D) typename

A

Admin • 832.27K Points
Coach

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

  • (A) Converts the value into a string
  • (B) Clones the value
  • (C) Converts Option<T> into Option<&T>
  • (D) Converts Option<T> into Result<T, E>

A

Admin • 832.27K Points
Coach

Q. Which trait must be implemented to allow sorting with `.sort()`?

  • (A) Ord
  • (B) Clone
  • (C) Debug
  • (D) Eq

A

Admin • 832.27K Points
Coach

Q. What is the purpose of `std::cell::RefCell<T>`?

  • (A) Immutable shared data
  • (B) Compile-time borrow checking
  • (C) Runtime-checked interior mutability
  • (D) Prevent references

A

Admin • 832.27K Points
Coach

Q. Which of the following best describes `unsafe` in Rust?

  • (A) Turns off all type checks
  • (B) Allows using low-level operations
  • (C) Disables the compiler
  • (D) Used for testing only

A

Admin • 832.27K Points
Coach

Q. Which of the following is used to define asynchronous functions in Rust?

  • (A) await fn
  • (B) async fn
  • (C) task fn
  • (D) future fn

A

Admin • 832.27K Points
Coach

Q. What is the purpose of `.await` in Rust?

  • (A) Pauses the program forever
  • (B) Terminates a future
  • (C) Waits for an async operation to complete
  • (D) Starts a new thread

A

Admin • 832.27K Points
Coach

Q. Which module is required to use file operations in Rust?

  • (A) std::fs
  • (B) std::file
  • (C) std::io::file
  • (D) std::dir

A

Admin • 832.27K Points
Coach

Q. Which of the following defines a closure in Rust?

  • (A) fn(x) = x + 1;
  • (B) |x| x + 1
  • (C) lambda x: x + 1
  • (D) (x) -> x + 1

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