What is a descriptor?
A descriptor is the collection of attributes of a variable. In implementation, it is an area of memory that stores those attributes.
What are the advantages and disadvantages of decimal data types?
Advantages: They can precisely store decimal values within a restricted range
Disadvantages: Their range of values is restricted because no exponents are allowed and their storage representation is mildly wasteful.
What are the design issues for character string types?
The two most important design issues are whether strings should be a primitive type or a special kind of character array, and whether they should have static or dynamic length.
Describe the three string length options.
Static length: The length is set when the string is created and fixed.
Limited dynamic length: Strings can vary in length up to a declared fixed maximum.
Dynamic length: Strings can vary in length with no maximum.
Define ordinal, enumeration, and subrange types.
Ordinal type: A type where the range of possible values can be easily associated with the set of positive integers.
Enumeration type: An ordinal type where all possible values are named constants provided in the definition.
Subrange type: A contiguous subsequence of an ordinal type.
In what ways are the user-defined enumeration types of C# more reliable than those of C++?
In C#, enumeration types are never coerced to integer, whereas C++ allows them to be used as integers.
What are the design issues for pointer types?
Issues include
- the scope/lifetime of the pointer
- lifetime of the heap variable
- type restrictions
- use for indirect addressing vs. dynamic management
- support for reference types.
What are the two common problems with pointers?
Dangling pointers (pointing to deallocated variables) and lost heap-dynamic variables
Why are the pointers of most languages restricted to pointing at a single type variable?
It is required for type checking and for pointer arithmetic (so the system knows how to scale the address index).
What is a C++ reference type, and what is its common use?
It is a constant pointer that is always implicitly dereferenced, commonly used for formal parameters in function definitions.
Why are reference variables in C++ better than pointers for formal parameters?
They allow two-way communication like pointers but are implicitly dereferenced, making code more readable and safer.
What advantages do Java and C# reference type variables have over the pointers in other languages?
They provide the flexibility of pointers without the dangers of dangling pointers (due to implicit deallocation).
Describe the lazy and eager approaches to reclaiming garbage.
Eager: Reclamation is incremental and happens when inaccessible cells are created.
Lazy: Reclamation occurs only when the list of available space becomes empty.
Why wouldn’t arithmetic on Java and C# references make sense?
Because references refer to objects rather than memory addresses, so address arithmetic is not sensible.