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).
  1. [Pts 2] In the stack-based implementation of imperative programming languages, the heap is (only one answer, please):
    1. not necessary, all dynamic allocation is done on the stack
    2. necessary for the allocation of the dynamic variables
    3. necessary for the allocation of the activation records
    4. necessary for the allocation of the local variables

  2. [Pts 2] The activation record associated to a function call contains storage for (only one answer, please):
    1. the formal parameters of the caller
    2. the dynamic link to the activation record of the caller
    3. the source code of the caller
    4. the pointer to the free list in the heap

  3. [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):
    1. the activation record of g
    2. the activation record of h
    3. the activation record of the function where h is declared
    4. the static part of the memory (base of the stack)

  4. [Pts 2] A dynamic variable pointed by p is allocated by (only one answer, please):
    1. a declaration of the form int* p;
    2. a declaration of the form int p;
    3. an instruction of the form p = q;
    4. an instruction of the form p = new int;

  5. [Pts 2] Which of the following fragments of code produces a dangling pointer at the end (only one answer, please):
    1. int* p = new int; int* q = p; q = NULL;
    2. int* p = new int; delete p; p = NULL;
    3. int* p = new int; int* q = new int; delete p; p = q;
    4. int* p = new int; int* q = p; delete p; p = NULL;