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:
- Stack-Dynamic
- Explicit Heap-Dynamic
- 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
3.
OR
OR