// A mutable set of Numbers class NumberSet { // @effects makes a new empty Numb
ID: 3739294 • Letter: #
Question
// A mutable set of Numbers
class NumberSet {
// @effects makes a new empty NumberSet
public NumberSet();
// @returns n ? this
public boolean contains(Number n);
// @modifies this
// @effects thispost = thispre ? { n }
public void add(Number n);
}
// A mutable set of Integers
class IntegerSet {
// @effects makes a new empty IntegerSet
public IntegerSet();
// @requires n is an Integer
// @returns n ? this
public boolean contains(Number n);
// @requires n is an Integer
// @modifies this
// @effects thispost = thispre ? { n }
public void add(Number n);
}
Circle the correct statement. Explain your answer.
a) NumberSet is a true subtype of IntegerSet
b) IntegerSet is a true subtype of NumberSet
c) Neither is a true subtype of the other
Explanation / Answer
a) NumberSet is a true subtype of IntegerSet
False, because NumberSet is not extending IntegerSet
b) IntegerSet is a true subtype of NumberSet
False, because IntegerSet is not extending NumberSet
c) Neither is a true subtype of the other
TRUE
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.