CMSC330_11/12

CMSC 330 — Fall 2026 · November 12, 2026 · 175 players · Max 10 pts

Questions & Results

Q1 of 10Multiple ChoiceAccuracy45s · 1 pt

What does this evaluate to?

{
  let x = 5;
  let x = x * 2;
  x
}
A 5
2
B 10
111
✓ Correct
C Error: cannot assign twice to immutable variable
46
D ()
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
}
A 3
14
B "big"
9
C Error
147
✓ Correct
D 0
170 / 175 answered · 86% correct
Q3 of 10Multiple ChoiceAccuracy45s · 1 pt

What does this evaluate to?

{
  let x = 3;
  x + 1;
}
A 4
34
B 3
4
C Error
44
D ()
91
✓ Correct
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; }
};
A 8
1
B 16
172
✓ Correct
C 10
D ()
1
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
}
A 6
117
✓ Correct
B 10
44
C 0
4
D Error
3
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;
A a: i64, b: f32
4
B a: u32, b: f64
18
C a: i32, b: f64
149
✓ Correct
D a: isize, b: f32
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
13
B c is 9, because b is converted to i32
7
C It compiles, but panics at run time
10
D Compile-time type error
142
✓ Correct
172 / 175 answered · 83% correct
Q8 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the type of nums?

let nums = [1, 2, 3];
A [i32; 3]
158
✓ Correct
B [i32]
4
C Vec<i32>
7
D (i32, i32, i32)
4
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
4
B Returns 0
3
C The program panics at run time: index out of bounds
162
✓ Correct
D Returns the last element, 3
1
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
3
B The module is only compiled when running tests (e.g., `cargo test`)
151
✓ Correct
C The module's console output is shown during testing
14
D The module can only be used from the `tests/` directory
4
172 / 175 answered · 88% correct

Score Distribution

1
3
6
5
8
29
40
61
22
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
175
Average Score
8
High Score
10
Max Possible
10