Question

In: Computer Science

2. Describe one advantage and one disadvantage for each of the following design decisions: a. having...

2. Describe one advantage and one disadvantage for each of the following design decisions:

a. having a garbage collector

b. type coercion

c. dynamic length strings

Solutions

Expert Solution

A]Garbage Collector

garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program.

here are some advantage and disadvantage for having garbage collector.

Advantage:

1)The allocation of free objects is simple and fast.

2)This method does not cause memory fragmentation, even when objects of different sizes are copied.

Disadvantage:

1)Although garbage collector runs in its own thread, still it has impact on performance.

2)Garbage collector can be force to run using "System.gc" or "Runtime.gc".

B] Type Coercion

is the process of converting value from one type to another such as string to number, object to boolean, and so on. Any type, be it primitive or an object, is a valid subject for type coercion.

Advantage:

1) It basically free the programmer from the low level concerns upto some level. as Adding two different data types Real & int

Disadvantage:

1)some level is reduced which may be that it hides some serious errors which will not be easy to point out.

C]Dynamic length strings:

Allows strings various length with no maximum. Requires the overhead of dynamic storage allocation and deallocation but provides flexibility.

Advantage:

1)Strings can be stored in a linked list Complexity of string operations, pointer chasing

Disadvantage:

1)Need run-time descriptor b/c only current length needs to be stored.


Related Solutions

describe one advantage and one disadvantage of having PLCs. Would you want to be on a...
describe one advantage and one disadvantage of having PLCs. Would you want to be on a school site that uses PLCs to analyze student data? Explain.
1. Advantage of a single-sample design. 2. Disadvantage of a single-sample design. 3. Advantage of a...
1. Advantage of a single-sample design. 2. Disadvantage of a single-sample design. 3. Advantage of a within subjects design. 4. Disadvantage of a within subjects design. 5. Advantage of a between subjects design. 6. Disadvantage of a between subjects design. 7. Advantage of a matached subjects design. 8. Disadvantage of a matched subjects design. * please list in order, and type up
List at least three surface imaging techniques, and describe advantage and disadvantage of each one.
List at least three surface imaging techniques, and describe advantage and disadvantage of each one.
Identify whether each attribute in the following table is an advantage or disadvantage of sharing a...
Identify whether each attribute in the following table is an advantage or disadvantage of sharing a currency across country boundaries. Attribute Advantage Disadvantage Price stability Limited scope for fiscal policy Lower transaction costs Speculative attacks during currency transition Protection from monetary disturbances and speculation Which of the following are reasons the European Union is considered   currency area? Check all that apply. Labor immobility Limited use of fiscal policy Low economic efficiency gains No legal or cultural barriers to labor mobility...
Describe one advantage and one disadvantage of trying to solve molecular protein structures by 1) X-ray...
Describe one advantage and one disadvantage of trying to solve molecular protein structures by 1) X-ray crystallography and by 2) Nuclear Magnetic Resonance (NMR) spectroscopy
Discuss the advantage and disadvantage of each major media types.
Discuss the advantage and disadvantage of each major media types.
What are one advantage and one disadvantage of allowing the modification of loop variables in the...
What are one advantage and one disadvantage of allowing the modification of loop variables in the loop body?
Name one advantage of associating user threads with kernel thread? Suggest an advantage and disadvantage of...
Name one advantage of associating user threads with kernel thread? Suggest an advantage and disadvantage of using mailboxes over shared memory for inter-process communication.
And then an advantage and disadvantage of each approach. GNP and NI in the United States...
And then an advantage and disadvantage of each approach. GNP and NI in the United States Next though is how does the US government HELP creat GNP and NI. And then how can the US government HURT GDP and NI. As such how do YOU THINK we can define the governmental role most suitable for creating and sustaining a good, health, GDP and NI.
One advantage and one disadvantage of minimum wage with respect to poverty and inequality, and give...
One advantage and one disadvantage of minimum wage with respect to poverty and inequality, and give one example of each one?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT