



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




1
CSE331 Autumn 2010 Midterm Examination
November 10, 2010
(computers, web-enabled phones, etc.)
Possible points Points
A. Specifications 30
B. ADTs 30
C. Miscellaneous 30
Total 90
Don’t turn the page until the proctor gives the go ahead!
2
A. Specifications
specification X (down the left column) is stronger than specification Y (across the top
row), a – in the box if specification X is weaker than specification Y, an = in the box if
they are equivalent, and a • ••• in the box if they are none of +, - or =. You only need to
fill in the empty boxes in the lower-left triangular area.
requires knowledge of the implementation of both the type and the subtype. Briefly
explain (maximum of two sentences).
that it requires the client to read and understand all the code in the implementation
before using it. In a maximum of two sentences, give one other reason why using
implementation code is bad as an approach to specification.
αα αα < ββββ αααα ≤≤≤≤ ββββ αααα ≤≤≤≤ ββββαααα < ββββ αααα ≤≤≤≤ ββββ & αααα < ββββ αααα ≠≠≠≠ ββββ
α αα
α < β ββ
β =
α αα
α ≤ ≤≤
≤ β ββ
β
α αα
α ≤ ≤≤
≤ β ββ
β
α αα
α < β ββ
β
αααα ≤≤≤≤ ββββ & αααα < ββββ
αααα ≠≠≠≠ ββββ
4
sentences, explain why abstraction functions do not map abstract values to concrete
values.
5
C. Miscellaneous
in Java – for each, is it true or false, providing one sentence of justification.
a. hashCode can be determined at most once – that is, only when it is first
actually requested by a client and then it can be cached
b. It is easier to write immutable objects to disk.
c. Only need to check a representation invariant after construction, but not again
on the entry or exit from any other method in the class.
d. If an immutable object throws an exception, it's never left in an undesirable or
indeterminate state.
e. Subclassing of a Java class that has only immutable objects is easier because
pure typing is guaranteed in this situation.