latency.lab
Milestone Exam I

Fundamentals → RAII

Covers: Modules 00–04Pass: 75%Rule: closed-book

Before you start

Milestone Exam I

12 questions · pass at 75%

Q01
The linker reports "undefined reference to foo()". Most likely cause?
WhyUndefined reference is a link-time error: the declaration exists but no definition was found to link against.
Q02
Signed integer overflow in C++ is:
WhySigned overflow is UB. Unsigned overflow is defined wraparound.
Q03
Why represent a price of $150.25 as the integer 15025?
WhyDoubles cannot exactly represent most decimals, breaking equality and accumulating error. Integer ticks are exact.
Q04
A local variable inside a function lives on the ___ and is destroyed when ___.
WhyAutomatic storage: stack, destroyed at scope exit.
Q05
Which is a use-after-free bug?
WhyUse-after-free = accessing memory after it was freed. (A) is a leak, (C) is double-free.
Q06
const int* p means:
Whyconst left of * binds the data: the pointee is read-only, the pointer can be reseated.
Q07
int* const p means:
Whyconst right of * binds the pointer: fixed address, but the pointed-to int can change.
Q08
p[3] for a pointer p is equivalent to:
Whyp[i] == *(p + i); pointer arithmetic scales by element size.
Q09
A function returns &local. The caller then dereferences it. This is:
WhyThe local dies at return; its address is dangling. Using it is UB.
Q10
The single default difference between struct and class is:
WhyOnly the default member access differs.
Q11
Members of a class are initialized in:
WhyAlways declaration order, regardless of how you write the initializer list.
Q12
RAII means:
WhyRAII binds resource lifetime to object lifetime; the destructor releases on every exit path.
+ Note