Rust MCQs with answers Page - 23

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 is the purpose of match guards in Rust?

  • (A) To skip match arms
  • (B) To create loops
  • (C) To add extra conditions in match arms
  • (D) To define constants

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which function is used to convert a String to lowercase?

  • (A) to_lower()
  • (B) lowercase()
  • (C) to_lowercase()
  • (D) as_lowercase()

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the behavior of a move in Rust?

  • (A) Creates a copy
  • (B) Shares ownership
  • (C) Transfers ownership
  • (D) Modifies the original value

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which keyword is used to define a public item?

  • (A) export
  • (B) pub
  • (C) open
  • (D) global

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which macro is used to assert test conditions?

  • (A) check!
  • (B) match!
  • (C) assert!
  • (D) test!

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which keyword allows unsafe operations in Rust?

  • (A) unsafe
  • (B) danger
  • (C) raw
  • (D) expose

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which macro is used to print values to the console?

  • (A) printline!
  • (B) echo!
  • (C) write!
  • (D) println!

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the default return type of a Rust function without a return statement?

  • (A) None
  • (B) ()
  • (C) 0
  • (D) void

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. Which data type is used to store Unicode characters?

  • (A) char
  • (B) u8
  • (C) String
  • (D) byte

S

Shyam Dubey • 3.70K Points
Extraordinary

Q. What is the purpose of the derive attribute?

  • (A) Creates traits automatically
  • (B) Generates boilerplate code for traits
  • (C) Includes modules
  • (D) Creates macros

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