Consider the following code.
int a = 1;
int b = 1;
Function foo() {
print(a);
}
Function bar(int x, int y){
int a = 0;
foo() ;
x = 0 ;
b = b-y;
r = Y+1;
}
Function foobar() {
int r = 1 ;
bar(r,b);
print(b);
print(r);
}
Suppose that foobar() is called from the outermost scope. Which of the following statements is/are true?
I. If dynamic scoping is used, then the first digit printed is 1, regardless of how parameters are passed (by value, reference, or value-result).
II. If lexical scoping and pass-by-value-result are used, then the second digit printed is 1.
III. If lexical scoping and pass-by-value are used, then the third digit printed is 1.
A. III only
B. I and II only
C. II and III only
D. I, II, and III
Answer is given a A..In III lexical scope is mentioned..So how will the function bar( int x,int y) access the variable 'r'?..it is local to fooBar()..i think this will throw compilation error..can anyone verify.