CMSC330-09/17

CMSC 330 — Fall 2026 · September 17, 2026 · 188 players · Max 10 pts

Questions & Results

Q1 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

type point = { x : int; y : int }
let p = { x = 3; y = 4 }
p.x + p.y
A 7
167
✓ Correct
B 12
1
C 34
1
D It produces a type error
169 / 188 answered · 99% correct
Q2 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the type of the OCaml expression?

type student = { name : string; gpa : float }
fun s → s.gpa
A student → float
168
✓ Correct
B string → float
6
C float → student
1
D student → string
1
176 / 188 answered · 95% correct
Q3 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

type point = { x : int; y : int }
let p = { x = 1; y = 2 }
let p2 = { p with y = 5 }
p2.x + p2.y
A 3
2
B 6
175
✓ Correct
C 7
3
D It produces a type error
180 / 188 answered · 97% correct
Q4 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

let f x = if x > 0 then Some x else None in
f 5
A 5
23
B Some 5
148
✓ Correct
C None
D It produces a type error
2
173 / 188 answered · 86% correct
Q5 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

let get_default o =
  match o with
  | Some x → x
  | None → 0
in
get_default None
A 0
175
✓ Correct
B None
4
C Some 0
D It produces a type error
3
182 / 188 answered · 96% correct
Q6 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the type of the OCaml expression?

fun v →
  match v with
  | Some x → x + 1
  | None → 0
A int → int
5
B int option → int
149
✓ Correct
C 'a option → int
28
D int option → int option
4
186 / 188 answered · 80% correct
Q7 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

type shape = Circle of float | Square of float
let area s =
  match s with
  | Circle r → 3.14 *. r *. r
  | Square s → s *. s
in
area (Square 4.0)
A 16.
171
✓ Correct
B 8.
2
C 12.56
3
D It produces a type error
4
180 / 188 answered · 95% correct
Q8 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the type of the OCaml expression?

type color = Red | Green | Blue
fun c →
  match c with
  | Red → 1
  | Green → 2
  | Blue → 3
A color → int
183
✓ Correct
B int → color
1
C 'a → int
D color → color
1
185 / 188 answered · 99% correct
Q9 of 10Multiple ChoiceAccuracy60s · 1 pt

What happens when the following OCaml expression is evaluated?

exception Negative
let sqrt_safe x =
  if x < 0 then raise Negative else x
in
sqrt_safe (-1)
A It raises the exception Negative
172
✓ Correct
B It evaluates to -1
4
C It evaluates to 0
1
D It produces a type error
177 / 188 answered · 97% correct
Q10 of 10Multiple ChoiceAccuracy60s · 1 pt

What is the value of the OCaml expression?

let safe_div x y =
  try x / y
  with Division_by_zero → -1
in
safe_div 10 0
A -1
175
✓ Correct
B 0
1
C It raises Division_by_zero
10
D It produces a type error
186 / 188 answered · 94% correct

Score Distribution

1
2
3
1
1
4
6
26
54
90
0
1
2
3
4
5
6
7
8
9
10

Score (points) →

Players
188
Average Score
9
High Score
10
Max Possible
10