Rust MCQs with answers Page - 17

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 type is used for dynamically sized arrays in Rust?

  • (A) Array
  • (B) Tuple
  • (C) Vec<T>
  • (D) List<T>

A

Admin • 832.27K Points
Coach

Q. Which function adds an element to the end of a vector?

  • (A) push()
  • (B) append()
  • (C) insert()
  • (D) add()

A

Admin • 832.27K Points
Coach

Q. What is the output type of `iter.map(|x| x + 1)`?

  • (A) Vector
  • (B) Iterator
  • (C) Array
  • (D) Result

A

Admin • 832.27K Points
Coach

Q. What is the purpose of `Mutex<T>` in Rust?

  • (A) Shared immutable memory
  • (B) Thread synchronization
  • (C) Memory leak prevention
  • (D) Compile-time type checking

A

Admin • 832.27K Points
Coach

Q. Which crate is commonly used for asynchronous runtime in Rust?

  • (A) rand
  • (B) tokio
  • (C) serde
  • (D) rayon

A

Admin • 832.27K Points
Coach

Q. What does `Rc<T>` stand for?

  • (A) Remote counter
  • (B) Reference check
  • (C) Reference counted
  • (D) Runtime clone

A

Admin • 832.27K Points
Coach

Q. What is the output of `Some(3).is_some()`?

  • (A) false
  • (B) true
  • (C) None
  • (D) Error

A

Admin • 832.27K Points
Coach

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

  • (A) macro
  • (B) macro_rules!
  • (C) define!
  • (D) rules!

A

Admin • 832.27K Points
Coach

Q. What is the purpose of `Option<T>` in Rust?

  • (A) To handle errors
  • (B) To represent success or failure
  • (C) To represent a value that may or may not exist
  • (D) To represent concurrency

A

Admin • 832.27K Points
Coach

Q. What does `Some(3).unwrap()` return?

  • (A) None
  • (B) 3
  • (C) Error
  • (D) true

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