1 answer

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

Question:

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:

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

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

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


Answers

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

3. java.io.FileDescriptor works for opening a file having a specific name. If there is any content present in that file it will first erase all that content and put “Beginning of Process” as the first line. Instances of the file descriptor class serve as an opaque handle to the underlying machine-specific structure representing an open file, an open socket, or another source or sink of bytes.

  • The main practical use for a file descriptor is to create a FileInputStream or FileOutputStream to contain it.
  • Applications should not create their own file descriptors.

4.

  • Dynamically allocated block needs to be freed explicitly. Otherwise, it would lead to memory leak.
  • Uninitialized pointers might cause segmentation fault.
  • Arrays passed as a function parameter decay to a pointer to the first element of the array, obscuring whether the parameter is intended to point to an array or a single data element.
.

Similar Solved Questions

1 answer
Bella Donna Paid in capital in excess of par? Please answer promptly and show all work....
Bella Donna Paid in capital in excess of par? Please answer promptly and show all work. Question 2 O out of 0.5 points Bella Donna Company has 100,000 shares of $4 par common stock issued and outstanding as of January 1, 2018. The shares were originally issued for $9 per share. On February 3, 2018,...
1 answer
Explain the different between advocacy and guardianship? Do advocates have power of attorney over their clients?...
Explain the different between advocacy and guardianship? Do advocates have power of attorney over their clients? How do these powers impact on people under the age of 18?...
1 answer
3. You have read that the harvest of Oranges is very, very good this season. a)...
3. You have read that the harvest of Oranges is very, very good this season. a) Graph a label the TYPICAL S & D for Orange Juice. b) Now, graph the new Supply of it. c) Is the NEW EQ Price Higher or Lower? d) Is the NEW EQ Quantity Higher or Lower? e) Which Determinant of Supply is this?...
1 answer
Accounting
If a revenue expenditure is treated as a capital expenditure, thena. expenses are overstated and assets are overstated.b. expenses are overstated and owners' equity is understated.c. net income is overstated and owners' equity is understated.d. expenses are understated and owners' equity...
1 answer
2. The A on a cello string has a frequency of 440 Hz. Assuming the string...
2. The A on a cello string has a frequency of 440 Hz. Assuming the string is about 1m long, write an equation which describes the motion of the cello string when it is played. Are there any free parameters? 3. For that same cello string, what is the frequency of the first harmonic? Write arn equatio...
1 answer
Find the absolute minimum and maximum values of the function on the given region D. Be...
Find the absolute minimum and maximum values of the function on the given region D. Be sure to sketch D. f(x, y) = x+y-xy, D is the closed triangular region with vertices (0,0), (0,2), and (4,0). Hint: for this region, you have three lines, two are similar to the square problem and the hypothenuse ...
1 answer
After spinning of photo resist over a wafer with prefabricated microstructures that introduce certain topology (i.e....
After spinning of photo resist over a wafer with prefabricated microstructures that introduce certain topology (i.e. non-flat surface) as shown bellow. Given the fact a g-line UV light exposure system with 257nm wavelength (i.e. λ=257nm).Based on your best scientific judgment (i.e. hand calcu...
1 answer
Pilings are driven into the ground at a building site by dropping a 2150 kg object...
Pilings are driven into the ground at a building site by dropping a 2150 kg object onto them. What change in gravitational potential energy does the object undergo if it is released from rest 17.0 m above the ground and ends up 1.90 m above the ground? change in gravitational potential energy: J...
1 answer
12:30 LTE X R assignment - Chapter 11 Wenton Powersports produces dune buggies. They have three a...
USING R 12:30 LTE X R assignment - Chapter 11 Wenton Powersports produces dune buggies. They have three assembly lines, Razo "Baze and Tracer,named ater the partioular dune buggy models produced on those ines. Each assembly line was originally designed using the same target pro...
2 answers
I need help to journalize these transactions for accounting
I need help to journalize these transactions for accounting. Samantha purchased inventory costing 125,000 and sold 70% of the goods for 162,500 all purchases and sales were on account She later collected 25% of the accounts receivable Which is the perpetual inventory system inventory, revenues and ...
1 answer
Causes of systemic lupus erythematosus for each system
causes of systemic lupus erythematosus for each system...
1 answer
In a perfectly competitive market, if market demand increases as a result of advertising, the price...
In a perfectly competitive market, if market demand increases as a result of advertising, the price will .... in the shortrun and each firm will produce a ... quantity. A.increase, increase B.increase, decrease C.decrease, decrease D.stay the same, stay the same...
1 answer
A buyer is deciding where to invest his money. He can purchase either an apartment building,...
A buyer is deciding where to invest his money. He can purchase either an apartment building, an office building or a warehouse. He considers two states of nature, either economic conditions will be good or poor with respective probabilities of 0.6 and 0.4. The table below summarizes is profit in tho...
1 answer
The following frequency table summarizes 50 data values. What is the 50th percentile of the data?...
The following frequency table summarizes 50 data values. What is the 50th percentile of the data? Frequency 5 Value 3 3 5 7 8 9 10 2 12 13 14 15 16 3 Select the correct answer below: 15 16 Select the correct answer below: 7 2 Previous Page Next Page Page Question 15 (1 point) If A and B are independ...
1 answer
List five specific morphological features, other than their overall size or the size of the canines,...
List five specific morphological features, other than their overall size or the size of the canines, that are different between the mandible of a great ape and the mandible of a human. Be sure to include which version of the feature is found in apes and which version of the feature is found in human...
1 answer
Free Response 4 points) A Hot Wheels car with a mass of n is released from...
Free Response 4 points) A Hot Wheels car with a mass of n is released from rest at the top of a tra in a living room. The initial height of the car is h. Construct a function that will tell you what the car's speed will be when the car reaches gh, involving only the variable h and the constant g...
1 answer
Suppose Paul's utility depends on the amount of time spent playing on the Internet (x) and...
Suppose Paul's utility depends on the amount of time spent playing on the Internet (x) and the amount of time playing video games (y), and his utility function is U(x,y) = xy/(x+y). He has 20 hours of free time to spend on these two activities each week, and his goal is to maximize his utility. ...