Questions & Results
Q1 of 10Multiple ChoiceAccuracy45s · 1 pt
What does this evaluate to?
{
let x = 5;
let x = x * 2;
x
}
C Error: cannot assign twice to immutable variable 159 / 175 answered · 70% correct
Q2 of 10Multiple ChoiceAccuracy45s · 1 pt
What does this evaluate to?
{
let x = 3;
let y = if x > 2 { "big" } else { 0 };
x
}
170 / 175 answered · 86% correct
Q3 of 10Multiple ChoiceAccuracy45s · 1 pt
What does this evaluate to?
{
let x = 3;
x + 1;
}
173 / 175 answered · 53% correct
Q4 of 10Multiple ChoiceAccuracy60s · 1 pt
What is the value of y?
let mut x = 1;
let y = loop {
x = x * 2;
if x > 10 { break x; }
};
174 / 175 answered · 99% correct
Q5 of 10Multiple ChoiceAccuracy60s · 1 pt
What does this evaluate to?
{
let mut x = 0;
for i in 0..4 {
x = x + i;
}
x
}
168 / 175 answered · 70% correct
Q6 of 10Multiple ChoiceAccuracy45s · 1 pt
With no type annotations, what types does Rust infer for a and b?
let a = 42;
let b = 3.14;
C a: i32, b: f64✓ Correct 171 / 175 answered · 87% correct
Q7 of 10Multiple ChoiceAccuracy45s · 1 pt
What happens with this code?
let a: i32 = 7;
let b: f64 = 2.0;
let c = a + b;
A c is 9.0, because a is converted to f64 B c is 9, because b is converted to i32 C It compiles, but panics at run time D Compile-time type error✓ Correct 172 / 175 answered · 83% correct
Q8 of 10Multiple ChoiceAccuracy45s · 1 pt
What is the type of nums?
let nums = [1, 2, 3];
173 / 175 answered · 91% correct
Q9 of 10Multiple ChoiceAccuracy45s · 1 pt
What happens when get(nums, 4) is called?
fn get(a: [i32; 3], i: usize) -> i32 {
a[i]
}
let nums = [1, 2, 3];
get(nums, 4)
A Returns whatever value is in memory past the array C The program panics at run time: index out of bounds✓ Correct D Returns the last element, 3 170 / 175 answered · 95% correct
Q10 of 10Multiple ChoiceAccuracy45s · 1 pt
In a Rust unit test file, what does #[cfg(test)] on mod tests { ... } mean?
A Each function in the module runs automatically when the program starts B The module is only compiled when running tests (e.g., `cargo test`)✓ Correct C The module's console output is shown during testing D The module can only be used from the `tests/` directory 172 / 175 answered · 88% correct
Score Distribution
Score (points) →