1 Given Following Generic Program Var Avar Avar 10 Sub1 Function Sub1 Sub2 Print Avar Avar Q37150900

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 strategiesfor variables, give an example of how Java and/or Python useseach:

  1. Stack-Dynamic
  2. Explicit Heap-Dynamic
  3. Implicit Heap-Dynamic

3) What is a descriptor? What are the required entries in a Javaarray descriptor for an int and when must they be stored(compile-time or run-time)? Compare this to a Python descriptor foran int.

4) Identify and explain the two common problemswith C++ pointers?


Answer


to the toP Icvel viYonhyn man10 when we wil e Print Stakmn able rekrsto the most recent environment-一nina He 2Briets sPeak n

3.

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.