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).
- [Pts 2]
In the stack-based implementation of imperative programming languages,
the stack is used for (only one answer, please):
- the allocation of the dynamic variables
- the allocation of the local variables
- the allocation of the global variables
- storing the code of the functions when they are called
- [Pts 2]
An activation record for a function f is allocated
(only one answer, please):
- at the beginning of the execution of the program
- when the declaration of f is compiled
- the first time f is called, and only that time
- each time f is called
- [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):
- 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]
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):
- a memory leak
- a dangling pointer to the heap
- a dangling pointer to the stack
- noting, because y is still allocated
- [Pts 2]
What is the meaning of
delete p; (only one answer, please):
- it removes p from the stack
- it puts the variable p back into the free
list on the heap
- it removes the variable pointed by p from the stack,
and p may become a dangling pointer
- it puts the variable pointed by p back into the free
list on the heap, and p may become a dangling pointer