Problem Set:
15.What are the arguments for and against Java’s implicit
heap storage recovery, when compared with the explicit heap storage recovery
required in C++? Consider real-time systems.
Answer:
Implicit eliminates the creation of dangling pointers. Disadv: cpu-time to do recovery, sometimes when there’s plenty of heap storage so recovery isn’t necessary.
Implicit eliminates the creation of dangling pointers. Disadv: cpu-time to do recovery, sometimes when there’s plenty of heap storage so recovery isn’t necessary.
16.What are the arguments for the inclusion of strong type
checking in Java, although they were not included in C or C++?
Answer:
Java are strongly
typed in the same sense as Ada. Types can be explicitly cast, which could
result in a type error. However, there are rules of a language have an
important effect on the value of an arithmetic operator with one floating-point
operand and one integer operand is legal. The value of the integer operand is
coerced to floating-point, and a floating point operation takes place. This is
what is usually intended by the programmer.
17. What kind of conversion is called a
nonconverting cast? Explain with example in Ada language
Answer:
Ada is nearly strongly typed. It is only nearly strongly typed because it
allows programmers to breach the type-checking rules by specifically requesting
that type checking be suspended for a particular type conversion. This temporary
suspension of type checking can be done only when an instantiation of the
generic function Unchecked_Conversion is called. Such functions can be
instantiated for any pair of subtypes. One takes a value of its parameter type
and returns the bit string that is the parameter’s current value. No actual
conversion takes place; it is merely a means of extracting the value of a
variable of one type and using it as if it were of a different type. This kind
of conversion is sometimes called a nonconverting cast.
No comments:
Post a Comment