Spring 2002, CSE 428: Quiz 4.2 - 7 Feb 2002
Please write your Name, Student ID, and Section at the top of the page.
By default, this quiz will be returned in Section 2 (morning section).
- [Pts 2]
In the stack-based implementation of imperative programming languages,
the heap is (only one answer, please):
- not necessary, all dynamic allocation is done on the stack
- necessary for the allocation of the dynamic variables
- necessary for the allocation of the activation records
- necessary for the allocation of the local variables
- [Pts 2]
The activation record associated to a function call
contains storage for (only one answer, please):
- the formal parameters of the caller
- the dynamic link to the activation record of the caller
- the source code of the caller
- the pointer to the free list in the heap
- [Pts 2]
Assume that a function f is declared inside a function g,
and called inside a function h. The static link
of f points to (only one answer, please):
- the activation record of g
- the activation record of h
- the activation record of the function where h is declared
- the static part of the memory (base of the stack)
- [Pts 2]
A dynamic variable pointed by p is
allocated by (only one answer, please):
- a declaration of the form int* p;
- a declaration of the form int p;
- an instruction of the form p = q;
- an instruction of the form p = new int;
- [Pts 2]
Which of the following fragments of code produces a dangling pointer
at the end (only one answer, please):
- int* p = new int; int* q = p; q = NULL;
- int* p = new int; delete p; p = NULL;
- int* p = new int; int* q = new int; delete p; p = q;
- int* p = new int; int* q = p; delete p; p = NULL;