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

  Calls the function readarray to read data into the array

Write a function void readArray(int arr[], int length) to read in length many values into the array arr.

  How do you figure out how to declare a variable

How do you figure out how to declare a variable? How do you know what type of variable to use? What is the best way to name a variable and why? What are the differences between an integer variable and a floating point variable? When and why do dat..

  Calculate rental fee for different types of borrowable media

Assume that there is an abstract class called Vehicle, which has two concrete subclasses, Car and Truck. There is also an interface Loadable, which only Truck implements - calculate a rental fee for different types of borrowable media (e.g. books,..

  The program reads in names

Write a program and include the following methods. The program reads in names and ages (use 2 parallel arrays, maximum size 50) from a file called Stuff.dat.

  Java application prompt user to put in integer from keyboard

Write a java application that performs the following task: prompt user to put in an integer from the keyboard, search for the user input from the array created in step 1.

  Design and implement a small and simple email server

Design and implement a small and simple email server using the concept of web based information system (WBIS).

  What could you do to kill more mutants

What are the implications related to suite of unit test cases when some mutants are not killed and What could you do to kill more mutants?

  Implement a shopping cart class with user interface

project will be to implement a shopping cart class with user interface (UI) that contains main() in Net Beans. The UI class will be used to perform user input/output and to invoke the appropriate methods of shopping cart class. When your program star..

  Draw the uml diagram for the class

Draw the UML diagram for the class and then implement the class. Write a program that creates two rectangles objects, one with width 4 and height 40 and the other with width 3.5 and height 35.9

  Developing a java application

You have been requested to develop a Java application for the local library as part of an upgrade initiative. As in all libraries, this is a place where one can check out books

  Describe the applications functionality

Create an application for Koch's Cottages, a weekend getaway resort that rents cottages and boats to use on the local lake - Add labels as suitable to describe the application's functionality. Save the file as JCottageFrame.java.

  Role of setter and getter in mortgage calculator

The setter and getters must stay in MortgageCalculator.java and everything should output from main (Driver.java).

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