Runtime Environment · Compiler Design
10 questions · asked in 9 of 27 years (2000–2026)
MCQ 101-mark 8 · 2-mark 2
2000Questions per year2026
Questions 1–5 of 10
In C runtime environment, which one of the following is stored in heap?
Answer: (C)
Look at how the C runtime memory model stores each item:
- A static variable declared inside a function goes in the data/BSS segment, not the heap. It lives for the whole program.
- An array declared inside a function that is not static and not dynamically allocated is a local (automatic) variable. It is kept on the stack.
- The return address of a function call is pushed onto the stack. It is part of the function's activation record (call frame).
- Only memory taken with (or similar dynamic allocation calls) comes from the heap. The programmer controls its lifetime until is called.
Answer: A dynamically allocated array of integers created using malloc()
- A static variable declared inside a function goes in the data/BSS segment, not the heap. It lives for the whole program.
- An array declared inside a function that is not static and not dynamically allocated is a local (automatic) variable. It is kept on the stack.
- The return address of a function call is pushed onto the stack. It is part of the function's activation record (call frame).
- Only memory taken with (or similar dynamic allocation calls) comes from the heap. The programmer controls its lifetime until is called.
Answer: A dynamically allocated array of integers created using malloc()
Consider the following statements.
S1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
S2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Which one of the following options is correct?
S1: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
S2: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.
Which one of the following options is correct?
Answer: (C)
In an activation tree, a procedure is called (visited) before its children are. So the calls follow preorder. A procedure returns only after all of its children have returned. So the returns follow postorder.
Answer: S1 is true and S2 is true
Answer: S1 is true and S2 is true
Match thefollowing:
Answer: (B)
- P. Lexical analysis (iii) regular expressions. Token patterns are written as regular expressions.
- Q. Top-down parsing (i) leftmost derivation. A top-down parser expands the leftmost non-terminal first, so it traces a leftmost derivation.
- R. Semantic analysis (ii) type checking. Type checking is a main part of semantic analysis.
- S. Runtime environments (iv) activation records. The runtime environment keeps an activation record for each procedure call.
This is P-iii, Q-i, R-ii, S-iv.
Answer: (B)
- Q. Top-down parsing (i) leftmost derivation. A top-down parser expands the leftmost non-terminal first, so it traces a leftmost derivation.
- R. Semantic analysis (ii) type checking. Type checking is a main part of semantic analysis.
- S. Runtime environments (iv) activation records. The runtime environment keeps an activation record for each procedure call.
This is P-iii, Q-i, R-ii, S-iv.
Answer: (B)
Which one of the following is NOT performed during compilation?
Answer: (A)
The compiler carries out type checking, symbol table management and inline expansion.
Dynamic memory allocation (malloc/new) takes place only at run time, when the program is running.
Answer: Dynamic memory allocation
Dynamic memory allocation (malloc/new) takes place only at run time, when the program is running.
Answer: Dynamic memory allocation
Which of the following statements are CORRECT?
1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
2) Automatic garbage collection is essential to implement recursion.
3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.
1) Static allocation of all data areas by a compiler makes it impossible to implement recursion.
2) Automatic garbage collection is essential to implement recursion.
3) Dynamic allocation of activation records is essential to implement recursion.
4) Both heap and stack are essential to implement recursion.
Answer: (D)
Let us go through the statements one by one:
- 1: In static allocation, every function gets only one fixed data area. A recursive call would write over it This is True.
- 2: Recursion does not need garbage collection This is False.
- 3: Every call must have its own activation record, made at run time This is True.
- 4: A stack is enough, and a heap is not required This is False.
Answer: 1 and 3 only
- 1: In static allocation, every function gets only one fixed data area. A recursive call would write over it This is True.
- 2: Recursion does not need garbage collection This is False.
- 3: Every call must have its own activation record, made at run time This is True.
- 4: A stack is enough, and a heap is not required This is False.
Answer: 1 and 3 only
Keep practising
Topics in Compiler Design
Lexical AnalysisParsingSyntax-directed Translation
Runtime EnvironmentYou are here
Assemblers, Linkers and LoadersIntermediate Code GenerationMatching