Rust MCQs with answers Page - 18

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. Which function would you use to clone a `String` in Rust?

  • (A) copy()
  • (B) clone()
  • (C) to_string()
  • (D) string()

A

Admin • 833.24K Points
Coach

Q. Which type provides runtime-checked borrowing in Rust?

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

A

Admin • 833.24K Points
Coach

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

  • (A) class
  • (B) object
  • (C) struct
  • (D) data

A

Admin • 833.24K Points
Coach

Q. Which syntax is correct for a mutable reference?

  • (A) &mut var
  • (B) mut &var
  • (C) &var mut
  • (D) mut var&

A

Admin • 833.24K Points
Coach

Q. Which method consumes an iterator and returns the sum?

  • (A) collect()
  • (B) sum()
  • (C) count()
  • (D) fold()

A

Admin • 833.24K Points
Coach

Q. What is `cargo` in Rust?

  • (A) A debugger
  • (B) A compiler
  • (C) A package manager and build tool
  • (D) A testing framework

A

Admin • 833.24K Points
Coach

Q. Which command creates a new Rust project?

  • (A) rust new
  • (B) cargo init
  • (C) cargo start
  • (D) rustc new

A

Admin • 833.24K Points
Coach

Q. Which of the following is used to include external crates?

  • (A) include!
  • (B) crate!
  • (C) extern crate
  • (D) use crate

A

Admin • 833.24K Points
Coach

Q. Which file contains dependency declarations in a Rust project?

  • (A) dependencies.json
  • (B) Cargo.lock
  • (C) Cargo.toml
  • (D) rust.config

A

Admin • 833.24K Points
Coach

Q. Which trait allows comparison using == in Rust?

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

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