1. What is an activation record?
A) A data structure that stores global variables
B) A record that stores information related to a single execution of a function
C) A memory block that stores compiled code
D) A record for storing function pointers in a linked list
Answer: B) A record that stores information related to a single execution of a function
2. Which of the following is typically stored in an activation record?
A) Return address
B) Local variables
C) Parameters passed to the function
D) All of the above
Answer: D) All of the above
3. What is the primary purpose of an activation record in a function call?
A) To store the global variables of a program
B) To hold the program code during execution
C) To hold the information needed to manage the function call and return
D) To manage memory allocation for the entire program
Answer: C) To hold the information needed to manage the function call and return
4. Where is the activation record usually stored during program execution?
A) Stack
B) Heap
C) Data segment
D) Code segment
Answer: A) Stack
5. Which of the following is NOT typically included in an activation record?
A) Local variables
B) Parameters
C) Return address
D) Global variables
Answer: D) Global variables
6. What is the role of the return address in an activation record?
A) To store the address of the next instruction after the function call
B) To store the memory location of the local variables
C) To store the value of the function’s result
D) To store the current function’s execution context
Answer: A) To store the address of the next instruction after the function call
7. When a function is called, an activation record is pushed onto the stack. What happens when the function finishes execution?
A) The activation record is transferred to the heap
B) The activation record is removed from the stack
C) The activation record is copied to the data segment
D) The activation record is copied to the code segment
Answer: B) The activation record is removed from the stack
8. Which of the following is the primary function of storage allocation during program execution?
A) To allocate memory for function calls and local variables
B) To allocate memory for function pointers
C) To allocate memory for global variables
D) To compile the source code into machine code
Answer: A) To allocate memory for function calls and local variables
9. In the context of activation records, what does storage allocation refer to?
A) The process of determining the memory layout for the activation record
B) The process of storing global variables
C) The process of linking function calls
D) The process of converting the code to machine language
Answer: A) The process of determining the memory layout for the activation record
10. Which of the following is typically found in the frame pointer of an activation record?
A) The return address
B) The address of the local variables
C) The address of the caller’s activation record
D) The value of the function’s result
Answer: C) The address of the caller’s activation record
11. What is the purpose of the dynamic link in an activation record?
A) To point to the local variables of the current function
B) To store the return address
C) To link the current activation record to the previous one in the call stack
D) To store the function’s output
Answer: C) To link the current activation record to the previous one in the call stack
12. Which of the following best describes stack unwinding?
A) A process that involves moving activation records from the heap to the stack
B) A process that removes activation records from the stack when a function call returns
C) A process that allocates memory for global variables
D) A process that compiles the source code during execution
Answer: B) A process that removes activation records from the stack when a function call returns
13. Which of the following is NOT true about activation records?
A) They are created when a function is called
B) They store the return address for the function
C) They are stored in the heap during program execution
D) They are removed from the stack once the function finishes execution
Answer: C) They are stored in the heap during program execution
14. In a function call, where are local variables and function parameters stored?
A) In the activation record of the calling function
B) In the activation record of the called function
C) In the heap
D) In the global data segment
Answer: B) In the activation record of the called function
15. In the context of storage allocation, what is a static storage allocation?
A) Memory allocation that happens at runtime
B) Memory allocation that happens before program execution and stays fixed during execution
C) Memory allocation that happens when a function is called
D) Memory allocation that happens when a variable goes out of scope
Answer: B) Memory allocation that happens before program execution and stays fixed during execution
16. What is the significance of the static link in an activation record?
A) It points to the local variables of the current function
B) It points to the previous function’s activation record in the call stack
C) It links the current function’s activation record to the global data segment
D) It points to the activation record of the function that called the current function
Answer: D) It points to the activation record of the function that called the current function
17. What is the effect of a memory leak in terms of activation records?
A) It leads to unnecessary removal of activation records
B) It prevents activation records from being deallocated, leading to wasted memory
C) It causes activation records to be overwritten
D) It reallocates memory for each function call
Answer: B) It prevents activation records from being deallocated, leading to wasted memory
18. Which of the following best describes dynamic storage allocation?
A) Memory allocation that is fixed during compile time
B) Memory allocation that happens during runtime
C) Memory allocation that happens when the program is loaded
D) Memory allocation for function call addresses
Answer: B) Memory allocation that happens during runtime
19. What happens when a function recursively calls itself in terms of activation records?
A) New activation records are created for each recursive call and stacked on top of each other
B) The previous activation record is overwritten by the recursive function
C) The activation record is reused in each recursive call
D) No activation records are created
Answer: A) New activation records are created for each recursive call and stacked on top of each other
20. What happens if an activation record does not have enough space for the function’s local variables?
A) The program will crash immediately
B) A memory allocation error occurs
C) The system will move the activation record to the heap
D) The function will not execute
Answer: B) A memory allocation error occurs