Rust MCQs with answers Page - 1

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

Q. What is Rust primarily designed for?

  • (A) Web development
  • (B) Data analysis
  • (C) System programming
  • (D) Mobile development

A

Admin • 799.53K Points
Coach

Q. Which keyword is used to define a constant in Rust?

  • (A) const
  • (B) define
  • (C) let
  • (D) static

A

Admin • 799.53K Points
Coach

Q. What is ownership in Rust?

  • (A) A way to declare variables
  • (B) A memory management system
  • (C) A syntax rule
  • (D) A debugging tool

A

Admin • 799.53K Points
Coach

Q. Which macro is used to print to the console in Rust?

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

A

Admin • 799.53K Points
Coach

Q. Which of the following is the correct way to declare a mutable variable in Rust?

  • (A) let mut x = 5;
  • (B) mut x = 5;
  • (C) var x = 5;
  • (D) x := 5;

A

Admin • 799.53K Points
Coach

Q. What does the `unwrap()` method do in Rust?

  • (A) Deletes the value
  • (B) Wraps the value in an Option
  • (C) Extracts the value or panics if None
  • (D) Replaces the value

A

Admin • 799.53K Points
Coach

Q. Which trait is used to enable formatting with {}?

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

A

Admin • 799.53K Points
Coach

Q. Which of the following is NOT a Rust primitive type?

  • (A) u32
  • (B) i64
  • (C) char
  • (D) byte

A

Admin • 799.53K Points
Coach

Q. What does the `match` keyword do in Rust?

  • (A) It checks string equality
  • (B) It is used for pattern matching
  • (C) It creates loops
  • (D) It assigns values

A

Admin • 799.53K Points
Coach

Q. How does Rust ensure thread safety?

  • (A) Using garbage collection
  • (B) Using mutexes only
  • (C) Through ownership and borrowing rules
  • (D) Manual memory management