java chapter 13 part 1
In programming, a(n) _________________ is a group of objects that can be operated on together?
Collection
A difference between a collection and an array is that a collection _________________?
is dynamically resizable
The Java Collections framework contains _________________?
both interfaces and classes
The List interface _________________?
allows items to be inserted after creation
An advantage of using the ArrayList class over the Arrays class is that an ArrayList _________________?
capacity
If you have declared an ArrayList of Strings named myStrings, which of the following is not a legal method call?
myStrings.remove("onion");
Suppose you have declared an ArrayList of Integers named numbers with a capacity of 10, and that you have assigned values to the first six elements. Which of the following is not legal?
numbers.get(9);
When you create a class from which you will instantiate objects to store in an ArrayList, _________________?
you are not required to create either a toString() method or a compareTo() method
The method that can be used to sort an ArrayList is _________________?
Collections.sort()
All of the following classes contain a built-in compareTo() method except _________________?
Scanner
if you want to use Collections.sort() with a class you have created, you must _________________?
write your own compareTo() method
Which is not a requirement when you create a compareTo() method that overrides the Object class compareTo() method?
Its return type must be boolean.
Suppose you have created a Student class compareTo() method that is based on the value of a private idNum field. Assume the class contains a public getId() method that returns the idNum value. Also suppose that stu1's idNum is 345 and that stu2's idNum is 456. Which of the following returns 1?
stu2.compareTo(stu1)
Which of the following is true?
The ArrayList class works better than a LinkedList when you have to sequentially retrieve a lot of data.
An object that can be used in a foreach loop to process the elements in a Collection is a(n) _________________?
Iterator
A generic class is one that uses a(n) _________________?
type parameter
A generic method _________________?
uses at least one type parameter
A generic method _________________?
must have a type parameter that represents a reference type