Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
- Which two of the following interfaces are at the top of the hierarchies in the Java Collections Framework?
Set
Map
Queue
SortedMap
Collection
List
- Which of the following interfaces does not allow duplicate objects?
Queue
Set
List
- In order for objects in a
List
to be sorted, those objects must implement which interface and method?- True or false: The
element
method alters the contents of aQueue
.
Check your answers.
- Write a method with the signature:
that (1) traverses through the elements inpublic Collection<String> filter(Collection<String> c)c
using anIterator
, (2) checks whether each element meets a certain condition (in a separate methodcondition
which you do not need to define right now), and (3) if the object meets the condition, adds it to the newCollection
to return. The method should not modify theCollection c
. Design the method to work on any collection ofString
s. Only thecondition
method should have application-specific code; we will define this method as part of an application in the exercises for the Implementations lesson.- Write a method with the signature:
that returns a newpublic List<Integer> reverse(List<Integer> orginalList)List
that contains the sameInteger
objects as theoriginalList
argument, but in reverse order. The method should not modify theorginalList
object.
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.