Rust MCQs with answers Page - 6

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

Q. What does `.expect("msg")` do?

  • (A) Returns default value
  • (B) Prints an error message and returns None
  • (C) Returns value or panics with the given message
  • (D) Ignores the error silently

A

Admin • 833K Points
Coach

Q. Which of the following is true about Rust's type system?

  • (A) Rust is dynamically typed
  • (B) Rust is weakly typed
  • (C) Rust is statically and strongly typed
  • (D) Rust has no types

A

Admin • 833K Points
Coach

Q. What is the return type of a function that returns nothing?

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

A

Admin • 833K Points
Coach

Q. How is memory managed in Rust?

  • (A) Manually by programmer
  • (B) Through garbage collector
  • (C) Through ownership and borrowing
  • (D) Using memory pools

A

Admin • 833K Points
Coach

Q. What does the `&` symbol indicate in Rust?

  • (A) Reference
  • (B) Dereference
  • (C) Mutable access
  • (D) Pointer arithmetic

A

Admin • 833K Points
Coach

Q. What is the type of array `[1, 2, 3]` in Rust?

  • (A) Vec<i32>
  • (B) [i32]
  • (C) [i32; 3]
  • (D) array<i32>

A

Admin • 833K Points
Coach

Q. What is the output of `Some(5).unwrap_or(10)`?

  • (A) 10
  • (B) Some(5)
  • (C) None
  • (D) 5

A

Admin • 833K Points
Coach

Q. What keyword is used to define a trait in Rust?

  • (A) interface
  • (B) trait
  • (C) protocol
  • (D) abstract

A

Admin • 833K Points
Coach

Q. Which of the following best describes a trait?

  • (A) A data structure
  • (B) An interface defining behavior
  • (C) A type alias
  • (D) A macro

A

Admin • 833K Points
Coach

Q. How do you make a reference mutable in Rust?

  • (A) &mut var
  • (B) mut& var
  • (C) ref mut var
  • (D) var &mut

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