Reference no: EM13963554
Exceptions, Memory Management, and Concurrency
This question asks you to compare properties of exceptions in C++ and Java.
(a) In C++, objects may be reside in the activation records that are deallocated when an exception is thrown. As these activation records are deallocated, all of the destructors of these stack objects are called. Explain why this is a useful language mechanism.
(b) In Java, objects are allocated on the heap instead of the stack. However, an activation record that is deallocated when an exception is raised may con- tain a pointer to an object. If you were designing Java, would you try to call the ?nalize methods of objects that are accessible in this way? Why or why not?
(c) Brie?y explain one programming situation in which the C++ treatment of objects and exceptions is more convenient than Java and one situation in which Java is more convenient than C++.
(d) In languages that allow programs to contain multiple threads, several threads may be created between the point where an exception handler is established and the point where an exception is thrown. In the spirit of trying to abort any computation that is started between these two points, a programming language might try to abort all such threads when an exception is raised. In other words, there are two possible language designs:
- raising an exception affects only the current thread, or
- raising an exception aborts all threads that were started between the point where the exception handler is established and the point where the exception is thrown.
Which design would be easier to implement? Explain brie?y.
(e) Brie?y explain one programming situation in which you would like raising an exception to abort all threads that were started between the point where the exception handler is established and the point where the exception is thrown. Can you think of a programming situation in which you would prefer not to have these threads terminated?
Prove the efficiency of two carnot engines
: Prove that the efficiency of two Carnot engines operating in tandem, one going from a cold reservoir of temperature Tc to a hot reservoir ofTj, then the second going from a cold reservoir of temperature Tj to a hot reservoir of temperature Thmust ..
|
Problem regarding the actor computing
: The actor mail system provides asynchronous buffered communication and does not guarantee that messages (tasks in actor terminology) are delivered in the order they are sent. Suppose actor A sends tasks t1, t2, t3,... , to actor B and we want acto..
|
What is the book value of aca assets today
: ACA Computer Systems's balance sheet lists net fixed asset as $32 million. The fixed assets could currently be sold for $28 million. ACA's current balance sheet shows current liabilities of $12 million and net working capital of $8 million. What i..
|
Calculate probability that at a later time tf electron spin
: At t=0 this field is pointing in the x direction, but it rotates counterclockwise in the x-z plane with angular frequency ω, so that at any later time t this field is at an angle ωt relative to the x-axis:Calculate the probability that at a later t..
|
Exceptions-memory management and concurrency
: This question asks you to compare properties of exceptions in C++ and Java.
|
Smith-kline company maintains inventory
: Smith-Kline Company maintains inventory records at selling prices as well as at cost.
|
What is the tension in the support cable
: A certain steam engine has an output of 500 hp and its efficiency in the use of fuel is 14%. It burns fuel oil that has a heat of combustion of 10,000 cal/g. How many kg of oil does the engine consume each hour?
|
Problem regarding the java bytecode analysis
: One property of a Java program that is checked by the veri?er is that each object must be properly initialized before it is used. This property is fairly dif?cult to check. One relatively simple part of the analysis, however, is to guarantee that ..
|
The amount of the average investment for a proposed
: The amount of the average investment for a proposed investment of $120,000 in a fixed asset with a useful life of 4 years, straight-line depreciation
|