Rust MCQs with answers Page - 5

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.01K Points
Coach

Q. Which trait is required to print a struct using {:?}?

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

A

Admin • 832.01K Points
Coach

Q. What is the purpose of lifetimes in Rust?

  • (A) To manage variable names
  • (B) To determine scope of ownership
  • (C) To manage function calls
  • (D) To import external crates

A

Admin • 832.01K Points
Coach

Q. Which of the following types can be used for error handling?

  • (A) Result
  • (B) Option
  • (C) Error
  • (D) Both Result and Option

A

Admin • 832.01K Points
Coach

Q. What does the `Copy` trait allow?

  • (A) Cloning heap data
  • (B) Moving values
  • (C) Bitwise copying for simple types
  • (D) Copying structs only

A

Admin • 832.01K Points
Coach

Q. Which keyword is used to include external crates in Rust?

  • (A) include
  • (B) use
  • (C) extern crate
  • (D) import

A

Admin • 832.01K Points
Coach

Q. What is the purpose of the `use` keyword?

  • (A) Create modules
  • (B) Import paths into scope
  • (C) Define traits
  • (D) Compile code

A

Admin • 832.01K Points
Coach

Q. Which keyword allows matching on multiple patterns?

  • (A) match
  • (B) if let
  • (C) or
  • (D) |

A

Admin • 832.01K Points
Coach

Q. What does the `static` keyword define?

  • (A) A mutable variable
  • (B) A runtime constant
  • (C) A globally available constant
  • (D) A lifetime annotation

A

Admin • 832.01K Points
Coach

Q. What is the main advantage of Rust over C++?

  • (A) Faster compilation
  • (B) Memory safety without garbage collection
  • (C) Simpler syntax
  • (D) More libraries

A

Admin • 832.01K Points
Coach

Q. Which is the correct syntax for an infinite loop in Rust?

  • (A) while(true) {}
  • (B) loop {}
  • (C) for(;;) {}
  • (D) repeat {}

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