Chapter 13 Flashcards

1
Q

In programming, ______ is a group of objects that can be operated on together.

A

Collection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A difference between a collection and an array is that a collection

A

Is dynamically resizable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The Java Collections framework contains

A

Both interfaces and classes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The List interface

A

Allows items to be inserted after creation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

an advantage of using the ArrayList class over the Arrays class is that an ArrayList

A

Is dynamically resizable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

An ArrayList can hold

A

Any object type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The number of items an ArrayList can hold is its

A

Capacity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Legal method calls of ArrayList of Strings is

A

MyString.add(“onion”);, int s = myString.size();, and myStrings.add(0, “leek”);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

An ArrayList with a capacity of 10 and six elements are assigned

A

Number.set(1,55);, number.get(5);, and number.add(77) are legal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When you create a class from which you will instantiate objects to store in an ArrayList,

A

You are not required to create either a toString() method or a compareTo() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

The method that can be used to sort an ArrayList is

A

Collections.sort()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Integer, String, and Double all have _____ built-in

A

CompareTo() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

If you want to use Collections.sort() with a class you have created, you must

A

Write your own compareTo() method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Requirements when you create a compareTo)_ method that overrides the Object class compareTo() method are

A

It must accept a parameter, it return type should be int and return -1,0,1, and it must be named compareTo()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

The ArrayList class works better than a LinkedList when you

A

Have to sequentially retrieve a lot of data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

An object that can be used in a foreach loop to process the elements in a collection is a

A

Iterator

17
Q

A generic class is one that uses a

A

Type parameter

18
Q

A generic method uses

A

At least one type parameter

19
Q

A generic method must

A

Return a generic parameter