Rust MCQs with answers Page - 20

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 trait must be implemented to use a type in a HashMap key?

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

A

Admin • 833.24K Points
Coach

Q. What is the return type of println!() macro?

  • (A) bool
  • (B) String
  • (C) i32
  • (D) ()

A

Admin • 833.24K Points
Coach

Q. What does Box<T> provide in Rust?

  • (A) Heap allocation
  • (B) Pattern matching
  • (C) Copy semantics
  • (D) Thread safety

A

Admin • 833.24K Points
Coach

Q. What is the purpose of the impl keyword?

  • (A) Import crates
  • (B) Define modules
  • (C) Implement methods and traits
  • (D) Create errors

A

Admin • 833.24K Points
Coach

Q. Which is NOT a valid Rust keyword?

  • (A) match
  • (B) func
  • (C) impl
  • (D) const

A

Admin • 833.24K Points
Coach

Q. Which feature allows running multiple tasks concurrently in Rust?

  • (A) unsafe
  • (B) async/await
  • (C) trait
  • (D) panic

A

Admin • 833.24K Points
Coach

Q. Which keyword is used to import modules or functions?

  • (A) use
  • (B) import
  • (C) extern
  • (D) mod

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which of the following is the correct way to define a constant in Rust?

  • (A) let PI = 3.14;
  • (B) const PI: f64 = 3.14;
  • (C) #define PI 3.14
  • (D) static mut PI: f64 = 3.14;

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which type is used to handle operations that may produce an error?

  • (A) Option<T>
  • (B) Vec<T>
  • (C) Result<T, E>
  • (D) Match

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the default mutability of variables in Rust?

  • (A) Mutable
  • (B) Immutable
  • (C) Constant
  • (D) Volatile

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