Spring 2002, CSE 428: Solution of Quiz 4.3 - 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 1 (afternoon section).
  1. [Pts 2] In the stack-based implementation of imperative programming languages, the stack is used for (only one answer, please):
    1. the allocation of the dynamic variables
    2. the allocation of the local variables
    3. the allocation of the global variables
    4. storing the code of the functions when they are called

  2. [Pts 2] An activation record for a function f is allocated (only one answer, please):
    1. at the beginning of the execution of the program
    2. when the declaration of f is compiled
    3. the first time f is called, and only that time
    4. each time f is called

  3. [Pts 2] Assume that a function f is declared inside a function g, and called inside a function h. The dynamic 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] Assume p is a global pointer to int and consider the following declaration
       void f(int x){
          p = &x;
       }
    
    The execution of the code int y=5; f(y); leaves (only one answer, please):
    1. a memory leak
    2. a dangling pointer to the heap
    3. a dangling pointer to the stack
    4. noting, because y is still allocated

  5. [Pts 2] What is the meaning of delete p; (only one answer, please):
    1. it removes p from the stack
    2. it puts the variable p back into the free list on the heap
    3. it removes the variable pointed by p from the stack, and p may become a dangling pointer
    4. it puts the variable pointed by p back into the free list on the heap, and p may become a dangling pointer