CMSC330 Quiz 09/24

CMSC 330 — Fall 2026 · September 24, 2026 · 179 players · Max 10 pts

Questions & Results

Q1 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the type of ref?

A 'a → 'a ref
108
✓ Correct
B 'a ref → 'a
23
C unit → 'a ref
6
D 'a → 'a
2
139 / 179 answered · 78% correct
Q2 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the value of the OCaml expression?

let r = ref 5 in
r := !r + 1;
!r
A 6
136
✓ Correct
B 5
1
C 4
2
D It produces a type error
3
142 / 179 answered · 96% correct
Q3 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the value of !a after evaluation?

let a = ref 0 in
let b = a in
b := 42;
!a
A 42
124
✓ Correct
B 0
27
C It produces a type error
3
D Unbound value b
1
155 / 179 answered · 80% correct
Q4 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the value of !a after evaluation?

let a = ref 0 in
let b = ref !a in
b := 42;
!a
A 0
158
✓ Correct
B 42
2
C It produces a type error
1
D Unbound value a
161 / 179 answered · 98% correct
Q5 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the value of the OCaml expression?

let a = ref 5
let b = ref 5
a == b
A false
150
✓ Correct
B true
16
C It produces a type error
1
D It depends on the compiler
1
168 / 179 answered · 89% correct
Q6 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the value of the OCaml expression?

let x = ref 0 in
(x := 1; x := !x + 1; !x)
A 2
154
✓ Correct
B 1
15
C 0
1
D It produces a type error
170 / 179 answered · 91% correct
Q7 of 10Multiple ChoiceAccuracy60s · 1 pt

Which of the following does the OCaml language specification NOT guarantee?

A The order in which the two arguments to a function application are evaluated
145
✓ Correct
B The result of adding two integers
1
C The value that a let binding produces
26
D The type that a well-typed expression has
172 / 179 answered · 84% correct
Q8 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of p.x after evaluation?

type point = { mutable x : int; y : int }
let p = { x = 1; y = 2 }
let () = p.x <- p.x + 10
A 11
170
✓ Correct
B 1
C 10
1
D It produces a type error
3
174 / 179 answered · 98% correct
Q9 of 10Multiple ChoiceAccuracy45s · 1 pt

What is the value of x after evaluation?

let x = 5 in
let x = x + 1 in
x
A 6
153
✓ Correct
B 5
20
C 11
D It produces a type error
2
175 / 179 answered · 87% correct
Q10 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of result after evaluating the code?

let count = ref 0;;
let f x =
  count := !count + 1;
  x * !count;;

let result = [f 1; f 2; f 3];;
A [1; 4; 9]
144
B [3; 4; 3]
22
✓ Correct
C [1; 2; 3]
11
D It produces a type error
177 / 179 answered · 12% correct

Score Distribution

2
1
5
2
7
10
19
26
42
57
8
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
179
Average Score
7.4
High Score
10
Max Possible
10