07: Working with Lists
Submit this homework using Gradescope. You can type up your answers, or write legibly and scan them. Do not attempt to submit a paper copy in class, as it will not be accepted.
Suppose we write lists by listing the values of the elements between square braces. For example, the list [1, 3, 5, 7]
represents a List
of Integer
s, containing the first four odd numbers.
Let odd = [1, 3, 5, 7]
and even = [8, 6, 4, 2]
.
Assume each of the following happens in sequence, that is, if odd
is modified in one question, carry that value forward into the next question.
(1 point each)
A. What is the contents of odd
if we call odd.addAll(even)
?
B. What is the contents of odd
if we then call odd.sort(null)
?
C. What is the contents of odd
if we then call odd.removeAll(even)
?
D. What is the contents of odd
if we then call odd.retainAll(even)
?