Back to the 2026 paper

Module 3: Semantic Analysis, Symbol Table, Run-time environment

20262m

Under static scoping, the meaning of a variable reference is determined primarily by:
(i) Runtime call sequence
(ii) CPU register contents
(iii) Heap location
(iv) Lexical program structure

Worked SolutionAI Assisted

Answer: (iv) Lexical program structure

Explanation

In static (lexical) scoping, a variable reference is bound to the declaration found by looking at the textual nesting of blocks/procedures in the source code: first the innermost enclosing block, then the next one outward, and so on.

  • The binding can be decided at compile time, without running the program.
  • The call sequence at run time (option i) decides the binding only in dynamic scoping.
  • Registers (ii) and heap location (iii) have nothing to do with name resolution.
int x = 10;
void f() { printf("%d", x); }   // x refers to the global x
void g() { int x = 20; f(); }   // still prints 10 under static scoping

(iv)\boxed{\text{(iv)}}

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.