Explanation: Rust's ownership model ensures memory safety without a garbage collector, preventing memory leaks and data races.
Dear candidates you will find MCQ questions of Rust here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.
Share your questions by clicking Add Question
Explanation: Rust's ownership model ensures memory safety without a garbage collector, preventing memory leaks and data races.
Explanation: In Rust, 'let' defines an immutable variable by default. 'mut' is used to make it mutable.
fn main() {
let x = 5;
let y = x;
println!("{}", x);
}
Explanation: Since x is a primitive type (Copy trait), y gets a copy and x remains valid. Output is 5.
Explanation: The {:?} formatter requires the Debug trait to be implemented for the type.
Explanation: unwrap() retrieves the value inside an Option or Result, but panics if it's None or Err.
Explanation: Rust uses 'mut' to make a variable mutable; 'let' alone creates an immutable variable.
Explanation: Variables in Rust are immutable by default unless explicitly marked with 'mut'.
Explanation: Rust uses the 'fn' keyword to define functions.
Explanation: 'match' is used for pattern matching, similar to switch statements in other languages.
Explanation: The 'Clone' trait allows for explicit duplication of values.