Question

8. (10%) Consider the following JavaScript program: // The main program var x,y; function f10{ var y, z; function f20{ var x,
0 0
Add a comment Improve this question Transcribed image text
Answer #1

a static scoping xf2 y: f 2. fa 7. P: f2 q: not visible main – f3 – fl fa a fe y + p. b : 23 z: 2

Add a comment
Know the answer?
Add Answer to:
8. (10%) Consider the following JavaScript program: // The main program var x,y; function f10{ var...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider the following program, written in JavaScript-like syntax: // main program var x, y, z; function...

    Consider the following program, written in JavaScript-like syntax: // main program var x, y, z; function sub1() { var a, y, z; . . . } function sub2() { var a, b, z; . . . } function sub3() { var a, x, w; . . . } 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...

  • Consider the following JavaScript skeletal program: //the main program var x: function sub1 () { var...

    Consider the following JavaScript skeletal program: //the main program var x: function sub1 () { var x: function sub2 () { } } function sub3 () { } Assume the execution of this program is in the following unit order: main calls sub1 sub1 calls sub2 sub2 calls sub3 a. Assuming static scoping, which declaration of x is the correct one for a reference to x in: i. sub1 ii. sub2 iii. sub3 b. Repeat part a, but assume dynamic...

  • Answer only The following questions refer to the skeletal C++ program shown below. void f10 void...

    Answer only The following questions refer to the skeletal C++ program shown below. void f10 void £20 Part 8: (10 points) int a,c,di int main) int c,d eit void ri int b, e t) int a, b: 12( void 12( int b, d if (..) { int a, di / Line 1 (1) Assume that static scoping is used, indicate which version of each of the following variables will be visible at Line 1 by filling in each blank with...

  • Given the following Ada program: procedure Main is X, Y: Integer; procedure Sub1 is Y, Z:...

    Given the following Ada program: procedure Main is X, Y: Integer; procedure Sub1 is Y, Z: Integer; begin -- of Sub1 point 1 Sub2; end; -- of Sub1 procedure Sub2 is X: Integer; procedure sub3 (B: Integer) is W: Integer; begin -- of Sub3 point 2 end; -- of Sub3 begin -- of Sub2 point 3 Sub3 (X); end; -- of Sub2 begin -- of Main point 4 Sub1; end; -- of Main For each of the four marked points,...

  • 3- (3 pts) Consider the following Pascal program skeleton program main var a, b, c: integer;...

    3- (3 pts) Consider the following Pascal program skeleton program main var a, b, c: integer; procedure Sl; var x, b, c: integer procedure S2; var n, m, k: integer; end; end; procedure S3; var x, a, l: integer; end; end; List all of the variables, along with the program units where they are declared, that are visible in the bodies of S1, S2, and S3, assuming static scoping.

  • Consider the following JavaScript-like program: 1 function subl) 2 var x 4 function sub2) // crea...

    Consider the following JavaScript-like program: 1 function subl) 2 var x 4 function sub2) // creates a popup box alert (x) 9 function sub3) 10 var x x3 sub4 (sub2); 12 13 14 15 function sub4 (subx) 16 17 18 19 20 21 22 ub30 23 24 subl 0; var x subx ) Give the output of this program when executed using a. (2p) deep binding Solution b. (2p) shallow binding Solution C. (2p) ad-hoc binding Solution Consider the following...

  • programming languages in #f language QUESTION 4 Consider the following skeletal C program: void funi(void); /*...

    programming languages in #f language QUESTION 4 Consider the following skeletal C program: void funi(void); /* prototype */ void fun2(void); /* prototype */ void fun3(void); /* prototype */ void main() { int a, b, c; void fun1(void) { int b, c, d; void fun2 (void) { int c, d, e; void fun3(void) { int d, e, f, Assuming that dynamic scoping is used, what variables are visible during execution of the last function called in following calling sequence: main calls...

  • 1) Given the following ‘generic’ program. var aVar; aVar = 10; sub1(); function sub1 () {  &...

    1) Given the following ‘generic’ program. var aVar; aVar = 10; sub1(); function sub1 () {     Sub2();     Print (“ aVar = “ aVar + “\n”); } function sub2() {    var aVar;    aVar = 4; } What would be output under static-scoping rules? What would be output under dynamic-scoping rules? 2) Discuss and compare the following memory allocation strategies for variables, give an example of how Java and/or Python uses each: Stack-Dynamic Explicit Heap-Dynamic Implicit Heap-Dynamic 3) What is a descriptor?...

  • (10pts).   Consider the following: void fun1(void); void fun2(void); void fun3(void); void main() {    Int a,b,c;...

    (10pts).   Consider the following: void fun1(void); void fun2(void); void fun3(void); void main() {    Int a,b,c;    … } void fun1(void){    Int b,c,d;    … } void fun2(void){    Int c,d,e;    … } void fun3(void){    Int d,e,f;    … } Given the following calling sequences and assuming that dynamic scoping is used. What variables are visible during execution of the last function called? Include with each visible variable the name of the function in which it was...

  • Consider the following code: int a:=10 //global int b:=12 //global proc F a:= a-b proc P...

    Consider the following code: int a:=10 //global int b:=12 //global proc F a:= a-b proc P (M:proc) int a:=2 M() proc K int b:=3 P(F) K() //main program print(a) //built in function a- what does this code print if it uses dynamic scoping and deep binding? b- what does this code print if it uses dynamic scoping and shallow binding?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT