Rust MCQs with answers Page - 12

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 • 832.27K Points
Coach

Q. What does the `match` keyword do?

  • (A) Declares a test case
  • (B) Implements a loop
  • (C) Handles multiple patterns and branching logic
  • (D) Defines struct fields

A

Admin • 832.27K Points
Coach

Q. Which of these types allows dynamic dispatch?

  • (A) Box<T>
  • (B) Box<dyn Trait>
  • (C) Option<T>
  • (D) Vec<T>

A

Admin • 832.27K Points
Coach

Q. Which function is used to read user input in Rust?

  • (A) stdin.read()
  • (B) input()
  • (C) std::read()
  • (D) stdin().read_line()

A

Admin • 832.27K Points
Coach

Q. Which iterator method applies a function and flattens the result?

  • (A) map()
  • (B) flat_map()
  • (C) filter()
  • (D) collect()

A

Admin • 832.27K Points
Coach

Q. Which operator is used for borrowing in Rust?

  • (A) &
  • (B) *
  • (C) ^
  • (D) @

A

Admin • 832.27K Points
Coach

Q. What does the keyword `enum` define in Rust?

  • (A) An immutable list
  • (B) A function
  • (C) A data type with variants
  • (D) A macro

A

Admin • 832.27K Points
Coach

Q. What does `panic!()` do?

  • (A) Compiles with warning
  • (B) Raises a runtime error and stops the program
  • (C) Prints to stderr only
  • (D) Continues silently

A

Admin • 832.27K Points
Coach

Q. Which keyword is used to continue to the next loop iteration?

  • (A) next
  • (B) break
  • (C) skip
  • (D) continue

A

Admin • 832.27K Points
Coach

Q. Which trait must be implemented for a type to be hashed in a HashMap?

  • (A) Hash
  • (B) Ord
  • (C) PartialOrd
  • (D) Clone

A

Admin • 832.27K Points
Coach

Q. What is the purpose of the `derive` attribute in Rust?

  • (A) Defines a macro
  • (B) Automatically implements traits
  • (C) Runs a function
  • (D) Declares a constant

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