Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

14. Consider the following program, written in JAVASCRIPT-LIKE syntax main progr

ID: 3708674 • Letter: 1

Question

14. Consider the following program, written in JAVASCRIPT-LIKE syntax main program var x, y, Z; function subl ) var a, Y. zi function sub2 0 var a, b, z; function sub3 ) var a, x, w; Part1) Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last subprogram activated? Include with each visible variable the name of the unit where it is declared a. main calls subl; subl calls sub2; sub2 calls sub3. b. main calls subl; subl calls sub3 c. main calls sub2; sub2 calls sub3; sub3 calls subl d. main calls sub3; sub3 calls subl e. main calls subl; subl calls sub3; sub3 calls sub2 f. main calls sub3; sub3 calls sub2; sub2 calls sub1 Part2) Repeat 'Part1' with a static scoping

Explanation / Answer

Variables and name of the unit where it is visible during the execution of

last subprogram

a)

Y - from Sub1

B, Z - from Sub2

A, X, W - from Sub3

b)

Y, Z - from Sub1

A, X, W - from Sub3

c)

B - from Sub2

X, W - from Sub3

A, Y, Z - from Sub1

d)

X, W - from Sub3

A, Y, Z - from Sub1

e)

Y - from Sub1

X, W - from Sub3

A, B, Z - from Sub2

f)

X, W - from Sub3

B - from Sub2

A, Y, Z - from Sub1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote