Académique Documents
Professionnel Documents
Culture Documents
A HashSet
is a set Mark for Review
that is (1) Points
similar to
an
ArrayList.
A HashSet
does not
have any
specific
ordering.
True or
false?
True (*)
False
Correct
2. What is the output from the following code snippet?
Mark for Review
TreeSett=new TreeSet(); (1) Points
if (t.add("one"))
if (t.add("two"))
if (t.add ("three"))
t.add("four");
for (String s : t)
System.out.print (s);
twofouronethree
onetwothreefour
fouronethreetwo (*)
1213
12134
11234
A keyword that specifies a class whose objects are defined inside the
class. (*)
A list of elements that is dynamically stored.
True (*)
False
False (*)
False (*)
False
Correct
9. Which scenario best describes a queue?
Mark for Review
(1) Points
A pile of pancakes with which you add some to the top and remove
them one by one from the top to the bottom.
A row of books that you can take out of only the middle of the
books first and work your way outward toward either edge.
A line at the grocery store where the first person in the line is the
first person to leave. (*)
All of the above describe a queue.
Correct
10. To allow our classes to have a natural order we could implement the
Comparable interface. Mark for Review
True or false? (1) Points
True (*)
False
add(Key, Value)
get(Key, Value)
remove(Key, Value)
True (*)
False
Correct
13. Which searching algorithm involves using a low, middle, and high index
value to find the location of a value in a sorted set of data (if it exists)? Mark for Review
(1) Points
Sequential Search
Merge Sort
Selection Sort
Sequential Search
Bubble Sort (*)
Selection Sort
Merge Sort
1. Which
scenario Mark for Review
best (1) Points
describes
a queue?
A pile of pancakes with which you add some to the top and remove
them one by one from the top to the bottom.
A row of books that you can take out of only the middle of the books
first and work your way outward toward either edge.
A line at the grocery store where the first person in the line is the first
person to leave. (*)
All of the above describe a queue.
Correct
2. FIFO stands for:
Mark for Review
(1) Points
Fast Interface Fast Output
Fast In Fast Out
True (*)
False
Correct
4. A HashMap can only store String types.
True or false? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 6 Lesson 3.
6. Bubble
Sort is a Mark for Review
sorting (1) Points
algorithm
that
involves
swapping
the
smallest
value into
the first
index,
finding
the next
smallest
value and
swapping
it into the
next
index and
so on
until the
array is
sorted.
True or
false?
True
False (*)
False (*)
Correct
9. Which one of the following would initialize a HashSet raffleTickets which will
store the class RaffleTicket. Mark for Review
(1) Points
HashSet raffleTickets = new HashSet(); (*)
Correct
Which is
the Mark for Review
correct (1) Points
way to
initialize
a
HashSet?
String classMates = new
String();
classMates = new HashSet[String]();
A keyword that specifies a class whose objects are defined inside the
class. (*)
A list of elements that is dynamically stored.
Correct
14. Examine the code below. Which statement about this code is true?
Mark for Review
1.class Shape { } (1) Points
2.class Circle extends Shape { }
3.class Rectangle extends Shape { }
4.class Node { }
correct
15. Generic methods can only belong to generic classes.
True or False? Mark for Review
(1) Points
True
False (*)
Merge Sort
Selection Sort
False (*)
Correct
3. Why might a sequential search be inefficient?
Mark for Review
(1) Points
It utilizes the "divide and conquer" method, which makes the algorithm
more error prone.
It requires incrementing through the entire array in the worst case,
which is inefficient on large data sets. (*)
It involves looping through the array multiple times before finding the
value, which is inefficient on large data sets.
It is never inefficient.
Selection Sort
Binary Search
True (*)
False
6. Which statements,
inserted it at line 2, Mark for Review
will ensure that the (1) Points
code snippet will
compile
successfully.(Choose
Two):
2,//insert code
here
3. s.put
("StudentID", 123);
4.}
(Choose all correct answers)
ArrayList s= new ArrayList();
False
Correct
9. The following code will compile.
True or False? Mark for Review
(1) Points
class Node implements Comparable{
public int compareTo(T obj){return 1;}
}
class Test{
public static void main(String[] args){
Node nc=new Node<>();
Comparable com=nc;
}
True (*)
False
Correct
11. The local
petting Mark for Review
zoo is (1) Points
writing a
program
to be able
to collect
group
animals
according
to species
to better
keep
track of
what
animals
they
have.
Which of
the
following
correctly
defines a
collection
that may
create
these
types of
groupings
for each
species at
the zoo?
public class
animalCollection {ナ} (*)
public class
animalCollection(AnimalType T) {ナ}
public class
animalCollection {ナ}
public class
animalCollection(animalType) {ナ}
None of the these.
Correct
12. < ? extends Animal > would only allow classes or subclasses of Animal to
be used. Mark for Review
True or False? (1) Points
True (*)
False
Correct
13. ArrayList and Arrays both require you to define their size before use.
True or false? Mark for Review
(1) Points
True
False (*)
vegetables.get("Cabbage");
vegetables[0] = "Cabbage";
vegetables += "Cabbage";
Correct
1. A LinkedList
is a list of Mark for Review
elements (1) Points
that is
dynamically
stored.
True or
false?
True (*)
False
Correct
2. The Comparable interface defines the compareTo method.
True or false? Mark for Review
(1) Points
True (*)
False
Correct
3. Implementing the Comparable interface in your class allows you to define
its sort order. Mark for Review
True or false? (1) Points
True (*)
False
Correct
4. Which statements, inserted it at line 2, will ensure that the code snippet
will compile successfully.(Choose Two): Mark for Review
(1) Points
1.public static void main (String[]args) {
4.}
(Choose all correct answers)
HashMap s= new HashMap(); (*)
java.util.List
java.util.Collections
class Test{
public static void main(String[] args){
Node nc=new Node<>();
Comparable com=nc;
}
True (*)
False
Correct
9. What is the correct definition of Enumeration (or enum)?
Mark for Review
(1) Points
Code that initializes an ArrayList
True (*)
False
Correct
11. < ?
extends Mark for Review
Animal > (1) Points
is an
example
of a
bounded
generic
wildcard.
True or
False?
True (*)
False
Incorrect. Refer to Section 6 Lesson 1.
12. Selection sort is a sorting algorithm that involves finding the minimum value
in the list, swapping it with the value in the first position, and repeating Mark for Review
these steps for the remainder of the list. (1) Points
True or false?
True (*)
False
Correct
14. Why might a sequential search be inefficient?
Mark for Review
(1) Points
It utilizes the "divide and conquer" method, which makes the
algorithm more error prone.
It requires incrementing through the entire array in the worst case,
which is inefficient on large data sets. (*)
It involves looping through the array multiple times before finding the
value, which is inefficient on large data sets.
It is never inefficient.
False