Rust MCQs with answers Page - 31

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 trait should be implemented to allow a custom struct to be compared using < and >?

  • (A) PartialEq
  • (B) PartialOrd
  • (C) Ord
  • (D) Eq

R

Ravina • 3.96K Points
Extraordinary

Q. Which method returns an iterator that skips the first n elements?

  • (A) drop(n)
  • (B) skip(n)
  • (C) omit(n)
  • (D) take(n)

R

Ravina • 3.96K Points
Extraordinary

Q. Which smart pointer automatically deallocates memory when out of scope?

  • (A) Rc<T>
  • (B) Box<T>
  • (C) Arc<T>
  • (D) RefCell<T>

R

Ravina • 3.96K Points
Extraordinary

Q. Which crate provides serialization and deserialization in Rust?

  • (A) std::serialize
  • (B) serde
  • (C) ron
  • (D) dataio

R

Ravina • 3.96K Points
Extraordinary

Q. What happens if a variable is moved and then used again?

  • (A) It works as expected
  • (B) It panics at runtime
  • (C) It causes a compile-time error
  • (D) It gets cloned

R

Ravina • 3.96K Points
Extraordinary

Q. Which method appends one vector to another?

  • (A) merge()
  • (B) append()
  • (C) push_all()
  • (D) extend()

R

Ravina • 3.96K Points
Extraordinary

Q. Which of the following types are considered scalar types in Rust?

  • (A) Tuple
  • (B) Array
  • (C) f64
  • (D) Vec

R

Ravina • 3.96K Points
Extraordinary

Q. What does std::mem::replace do?

  • (A) Deletes a value
  • (B) Replaces value with another and returns the old
  • (C) Swaps memory addresses
  • (D) Copies memory

R

Ravina • 3.96K Points
Extraordinary

Q. Which method removes all elements from a Vec?

  • (A) clear()
  • (B) truncate(0)
  • (C) remove_all()
  • (D) drop()

R

Ravina • 3.96K Points
Extraordinary

Q. What is the result of 4 % 2 in Rust?

  • (A) 1
  • (B) 0
  • (C) 2
  • (D) 4

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