Initializing Variables & Flags

You may be puzzled why, when initializing variables, we sometimes give strange values such as -999 for a variable keeping track of age, or "not set yet" for a variable keeping track of student names. First of all, appreciate that we didn't have to. It is possible to declare variables without giving them an initial value. But this is not advised. Here's why. Even though when we garbage collect, the variable is no longer available, the actual binary 0s and 1s that made up the value of the variable are still in memory; they exist, they just aren't identified anymore as belonging to the specific variable name. So a variable pointing to a certain 32 bit space, for example will point to some combination of binary 0s and 1s; either containing the last value stored there, or just all 0s if that space had never been used before.

Note that the term "flag" (or "flag value") is sometimes interchangeable with the the term "sentinel" (or "sentinel value); the IB CS curriculum uses both.