Rust MCQs with answers Page - 32

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

R

Ravina • 3.96K Points
Extraordinary

Q. Which of the following is used for formatted writing to a buffer?

  • (A) formatln!
  • (B) write!
  • (C) print!
  • (D) println!

R

Ravina • 3.96K Points
Extraordinary

Q. Which function is used to execute a block of code after a thread finishes?

  • (A) join()
  • (B) sync()
  • (C) merge()
  • (D) wait()

R

Ravina • 3.96K Points
Extraordinary

Q. Which crate is commonly used for command-line argument parsing?

  • (A) clap
  • (B) args
  • (C) parseit
  • (D) getopt

R

Ravina • 3.96K Points
Extraordinary

Q. Which keyword is used to return a value early from a function?

  • (A) exit
  • (B) return
  • (C) stop
  • (D) break

R

Ravina • 3.96K Points
Extraordinary

Q. What is the default starting index for a for loop over a vector?

  • (A) 0
  • (B) 1
  • (C) -1
  • (D) None

R

Ravina • 3.96K Points
Extraordinary

Q. Which type is used to represent a dynamically sized string slice?

  • (A) str
  • (B) &str
  • (C) String
  • (D) *str

A

Admin • 832.01K Points
Coach

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

  • (A) let
  • (B) mut
  • (C) var
  • (D) change

A

Admin • 832.01K Points
Coach

Q. Which of the following is a valid way to define a function in Rust?

  • (A) function my_func() {}
  • (B) def my_func() {}
  • (C) fn my_func() {}
  • (D) func my_func() {}

A

Admin • 832.01K Points
Coach

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

  • (A) Compares two strings
  • (B) Pattern matching
  • (C) Loops over a collection
  • (D) Defines a macro

A

Admin • 832.01K Points
Coach

Q. Which trait allows a type to be duplicated in Rust?

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

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