CSE331 Autumn 2010 Midterm Examination: Specifications, ADTs, and Miscellaneous, Exams of Java Programming

The instructions and questions for the midterm examination of the cse331 course at autumn 2010. The examination covers specifications, abstract data types (adts), and miscellaneous concepts. Students are required to fill in the answer sheet within 50 minutes, with open notes, open books, but closed electronic devices.

Typology: Exams

2012/2013

Uploaded on 04/08/2013

savitha_48
savitha_48 🇮🇳

3

(1)

109 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
NAME:_____________________
1
CSE331 Autumn 2010 Midterm Examination
November 10, 2010
50 minutes
Open note, open book, closed neighbor, closed anything electronic
(computers, web-enabled phones, etc.)
An easier-to-read answer makes for a happier-to-give-partial-credit grader
Possible points
Points
A.
Specifications
30
B.
30
C
.
Miscellaneous
30
Total
90
Don’t turn the page until the proctor gives the go ahead!
pf3
pf4
pf5

Partial preview of the text

Download CSE331 Autumn 2010 Midterm Examination: Specifications, ADTs, and Miscellaneous and more Exams Java Programming in PDF only on Docsity!

1

CSE331 Autumn 2010 Midterm Examination

November 10, 2010

  • 50 minutes
  • Open note, open book, closed neighbor, closed anything electronic

(computers, web-enabled phones, etc.)

  • An easier-to-read answer makes for a happier-to-give-partial-credit grader

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

  1. (20 points) For each of the five specifications below, mark a + in the box if

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.

  1. (5 points) True or false: Determining whether or not a Java subtype is a true subtype

requires knowledge of the implementation of both the type and the subtype. Briefly

explain (maximum of two sentences).

  1. (5 points) Using implementation code as a specification is a poor idea. One reason is

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

  1. (5 points) Abstraction functions map concrete values to abstract values. In at most two

sentences, explain why abstraction functions do not map abstract values to concrete

values.

5

C. Miscellaneous

  1. (15 points) Consider the following list of possible benefits of using immutable objects

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.