Rust MCQs with answers Page - 29

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

R

Ravina • 3.96K Points
Extraordinary

Q. Which trait must be implemented to allow a type to be formatted using {:?}?

  • (A) Display
  • (B) ToString
  • (C) Debug
  • (D) Printable

R

Ravina • 3.96K Points
Extraordinary

Q. What is the main benefit of zero-cost abstractions in Rust?

  • (A) Faster compilation
  • (B) Smaller binaries
  • (C) Abstractions that compile to optimal machine code
  • (D) Automatic memory management

R

Ravina • 3.96K Points
Extraordinary

Q. Which keyword is used to match multiple patterns?

  • (A) or
  • (B) if
  • (C) |
  • (D) &

R

Ravina • 3.96K Points
Extraordinary

Q. Which method consumes a String and returns a vector of words?

  • (A) split_words()
  • (B) words()
  • (C) split_whitespace().collect()
  • (D) tokenize()

R

Ravina • 3.96K Points
Extraordinary

Q. Which type is used for file handling errors in Rust?

  • (A) Result<T, String>
  • (B) Option<T>
  • (C) Result<T, io::Error>
  • (D) Result<T, bool>

R

Ravina • 3.96K Points
Extraordinary

Q. Which macro is used to format strings without printing?

  • (A) format!
  • (B) print!
  • (C) write!
  • (D) concat!

R

Ravina • 3.96K Points
Extraordinary

Q. Which method is used to resize a vector?

  • (A) resize()
  • (B) adjust_size()
  • (C) extend()
  • (D) reallocate()

R

Ravina • 3.96K Points
Extraordinary

Q. Which operator is used for dereferencing a reference?

  • (A) &
  • (B) ->
  • (C) *
  • (D) ::

R

Ravina • 3.96K Points
Extraordinary

Q. Which trait is used for cloning data?

  • (A) Copy
  • (B) Clone
  • (C) ToOwned
  • (D) Owned

R

Ravina • 3.96K Points
Extraordinary

Q. Which keyword allows you to access fields from a parent struct?

  • (A) parent
  • (B) base
  • (C) super
  • (D) self

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