Rust MCQs with answers Page - 2

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 `cargo` do in Rust?

  • (A) Installs the Rust compiler
  • (B) Manages Rust packages and builds
  • (C) Edits Rust source code
  • (D) Visualizes Rust memory

A

Admin • 832.27K Points
Coach

Q. Which symbol is used to reference a variable in Rust?

  • (A) &
  • (B) *
  • (C) #
  • (D) $

A

Admin • 832.27K Points
Coach

Q. What does `Result<T, E>` represent in Rust?

  • (A) A successful operation only
  • (B) An asynchronous operation
  • (C) A value that can be Ok or Err
  • (D) A loop structure

A

Admin • 832.27K Points
Coach

Q. Which tool formats Rust code automatically?

  • (A) cargo-fix
  • (B) rustdoc
  • (C) rust-analyzer
  • (D) rustfmt

A

Admin • 832.27K Points
Coach

Q. What is the default integer type in Rust?

  • (A) i32
  • (B) i64
  • (C) u32
  • (D) usize

A

Admin • 832.27K Points
Coach

Q. What is `Option<T>` used for in Rust?

  • (A) To perform looping
  • (B) To handle file operations
  • (C) To express a value that may or may not be present
  • (D) To create classes

A

Admin • 832.27K Points
Coach

Q. Which keyword is used to create a module in Rust?

  • (A) mod
  • (B) module
  • (C) pkg
  • (D) use

A

Admin • 832.27K Points
Coach

Q. What does the `?` operator do in Rust?

  • (A) Creates a reference
  • (B) Marks a function as async
  • (C) Propagates errors
  • (D) Denotes a wildcard match

A

Admin • 832.27K Points
Coach

Q. Which of the following can cause a panic in Rust?

  • (A) Accessing an element out of bounds in a vector
  • (B) Compiling a program
  • (C) Using a match statement
  • (D) Using `let` keyword

A

Admin • 832.27K Points
Coach

Q. Which of the following keywords defines an enumeration in Rust?

  • (A) enum
  • (B) enumType
  • (C) union
  • (D) struct