Exceptions-memory management and concurrency

Assignment Help JAVA Programming
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?

Reference no: EM13963554

Questions Cloud

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

Reviews

Write a Review

JAVA Programming Questions & Answers

  Print the name and number

Question is to print the name and number you entered in order either asked by name or number.

  History of java

Add a class FillInQuestion to the question hierarchy of How To 10.1. An object of this class is constructed with a string that contains the answer, surrounded by _ _, for example, "The inventor of Java was _James Gosling_". The question should be ..

  Combine the four loop problems into one program

Combine the four loop problems into one program with four distinct methods (the data is in the attached document). For this problem you will write methods, two value returning methods and two void methods.

  Create a servlet to display a table

NetBeans for Java with GlassFish/Tomcat: https://netbeans.org/downloads/ (select All option)) and create a servlet to display a table that contains factorials for the numbers from 0 to 10, as shown

  Concepts of interfaces and inheritance

In this assignment we will work with the concepts of interfaces and inheritance. We will make use of a extends to create an inheritance hierarchy, and use implements to implement an interface that allows properties to be added to objects at run-ti..

  Write a java program that can serve as a simple calculator.

Write a Java program that can serve as a simple calculator. This calculator keeps track of a single number (of type double) that is called result and that starts out as 0.0.

  How java enabled high performance

How Java enabled High Performance? Why Java is considered dynamic? List two Java IDE's? List some Java keywordsunlikeC, C + + keywords?

  Writing a method to compute such an array from a string

Write a java program in one file to determine if a string is an anagram of another string where a typical run of your program is to be as follows. % java Assg3 restful fluster"restful" is an anagram of "fluster"

  Your program should ask the user to input a grade

Your program should ask the user to input a grade (integer from 1-100) and then output the letter grade.

  Use loops in the "equals" method to reduce the fractions

The equals method modification should loop repeatedly until the user decides to quit. Inside the body of the loop, the programshould allow the user to enter a target fraction into an anonymous object and learn whether the fractions are identical.

  Can we run java byte code on android since android

Can we run java byte code on android since android is also java based

  Evaluate the average temperature for the month

Write a program that stores the daily temperatures for the month of April in an array name dailytemp. Evaluate the average temperature for the month and the count the number of days

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd