Rust MCQs with answers Page - 25

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

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What will happen if a thread panics in Rust?

  • (A) Whole program crashes
  • (B) Thread stops but others continue
  • (C) It retries execution
  • (D) Program restarts

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which trait is used for formatting types as strings?

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

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which standard library module provides file operations?

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

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What does unwrap_or_else() accept as an argument?

  • (A) A default value
  • (B) A closure
  • (C) A match statement
  • (D) A reference

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which macro is used to include code from other files?

  • (A) include_file!
  • (B) use!
  • (C) include!
  • (D) mod!

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the use of the as keyword?

  • (A) Module import
  • (B) Type casting
  • (C) Defining constants
  • (D) Loop control

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which keyword makes a trait method optional to implement?

  • (A) fn default
  • (B) optional
  • (C) default
  • (D) base

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the return type of an if expression in Rust?

  • (A) Unit ()
  • (B) The type of the returned branch
  • (C) Boolean
  • (D) i32

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which of the following does not own heap memory?

  • (A) Box<T>
  • (B) Vec<T>
  • (C) String
  • (D) &str

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which trait must be implemented to sort a collection?

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

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