Rust MCQs with answers Page - 19

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 of the following is true about traits in Rust?

  • (A) Traits are similar to interfaces
  • (B) Traits cannot have methods
  • (C) Traits are used only for debugging
  • (D) Traits can only be used with structs

A

Admin • 833.24K Points
Coach

Q. What does unwrap_or() do in Rust?

  • (A) Always panics
  • (B) Returns an Option
  • (C) Returns the value or a default if None
  • (D) Converts the type

A

Admin • 833.24K Points
Coach

Q. Which type is used to create atomic reference counting in multi-threaded Rust?

  • (A) Rc<T>
  • (B) RefCell<T>
  • (C) Arc<T>
  • (D) Box<T>

A

Admin • 833.24K Points
Coach

Q. What is required to mutate a borrowed variable?

  • (A) Clone the variable
  • (B) Use RefCell<T>
  • (C) Use &mut reference
  • (D) Use Rc<T>

A

Admin • 833.24K Points
Coach

Q. What does the ? operator do in Rust?

  • (A) Matches a pattern
  • (B) Handles errors by propagating them
  • (C) Makes a value optional
  • (D) Converts an Option to a Result

A

Admin • 833.24K Points
Coach

Q. What is the size of a unit type in Rust?

  • (A) 1 byte
  • (B) 0 bytes
  • (C) Depends on the system
  • (D) Cannot be determined

A

Admin • 833.24K Points
Coach

Q. Which syntax correctly defines a tuple?

  • (A) {1, 2}
  • (B) [1, 2]
  • (C) (1, 2)
  • (D) <1, 2>

A

Admin • 833.24K Points
Coach

Q. What happens when a panic occurs in Rust?

  • (A) Program hangs
  • (B) Program continues
  • (C) Thread unwinds or aborts
  • (D) Compiler ignores it

A

Admin • 833.24K Points
Coach

Q. Which method consumes an iterator and collects the results into a Vec?

  • (A) to_vec()
  • (B) gather()
  • (C) collect()
  • (D) combine()

A

Admin • 833.24K Points
Coach

Q. Which operator is used to dereference a pointer in Rust?

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

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