Variable Binding

Question 1
 
A
x = 10, y = 10
B
x = 20, y = 10
C
x = 10, y = 20
D
x = 20, y = 20
       Programming       Variable Binding       Gate 2007-IT
Question 1 Explanation: 
Since the value of x is based on static scoping, in the procedure g( ), print i will directly look into the global scope and find i=10 which was previously set by main( ) and since the value of y is based on dynamic scope, procedure g( ) will first look into the function whicg called it, i.e., procedure f( ) which has a local i=20, which will be taken and 20 will be printed.
Question 2
 
A
Early, late, decrease, increase
B
Late, early, increase, decrease
C
Late, early, decrease, increase
D
Early, late, increase, decrease
       Programming       Variable Binding       Gate 2007-IT
Question 2 Explanation: 
Static scoping can do early binding (during compile time). Early binding increases efficiency.
Dynamic scoping requires late binding (during execution time).
Late binding decreases efficiency as this binding needs to be done at run time.
Question 3
 
A
1 2 1
B
2 1 1
C
2 1 2
D
2 2 2
       Programming       Variable Binding       Gate-2003
Question 3 Explanation: 
Because of using dynamic binding it results a values such as 2 2 2.
Note: The given question is not in the present syllabus
There are 3 questions to complete.