Question: You will be given multiple choices for each answer, one being None of the others . You will choose the answer that matches yours or
You will be given multiple choices for each answer, one being None of the others You will choose the answer that matches yours or None if that is the case.
Q For the following program FOO, assuming each scoping method:
a Static and
b Dynamic Scoping,
show the output x at locations The program execution begins execution in MAIN.
PROGRAM FOO
VAR x : integer; this is global
A
PROCEDURE A
VAR d : integer;
BEGIN
x :;
d :;
B; call to B
writelnx; output the value of x
END procedure A
B
PROCEDURE B BEGIN
writelnx; output the value of x
END procedure B
MAIN
PROCEDURE MAIN
VAR x : integer;
BEGINProgram starts here
x :;
A; call to A
writelnx; output the value of x
END
END. program FOO
a Static scoping? X:
b Dynamic scoping? X:
Q For the program in Q assuming Dynamic Scoping, what would be the referencing environment for statements when executing the first line so after the BEGIN in
a procedure Ainclude only variable names
b procedure Binclude only variable names
c procedure MAIN? include only variable names
Q True or False
a The declaration of a local variable with the same name as a nonlocal variable can only hide the nonlocal variable in the local scope when using Static Scoping but not when using Dynamic Scoping.
b A globally declared variable will always be visible everywhere in a program.
c Runtime overhead is the main reason Dynamic scoping is not chosen over Static scoping.
d The type and value are always bound to a variable name at the same time.
e A HeapDynamic variable typically requires the user to create a Reference or Pointer typed variable to allow them to be accessed by the user.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
