Chapter 16 Flashcards

1
Q

Java collections framework contain other ______ generic data-structures

A

Prebuilt

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

Examples of collections

A

Contacts list, music playlist, members of sport teams

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

What do iterators do

A

Walk through collections

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

A collection is a _____ ______ (actually an object) that can hold references to other objects

A

Data structure

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

Usually collections contain references to objects of any type that has the ______ ___________ (inheritance, composition is a has-a relationship) with the collection’s element type. The collections-framework interfaces declare the operations to be performed generically on various types of collections.

A

Is-a relationship

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

Interface Collection is the ______ __________ in the collections hierarchy from which interfaces Set, Queue and List are derived.

A

Root interface

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

The collections-framework classes and interfaces are members of package ________

A

Java.util

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

As a result, the Object references obtained from a collection needed to be ________ to an appropriate type to allow the program to process the objects correctly. __________ should be avoided

A

Downcast

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

Wrapper classes

A

Boolean, Byte, Character, Double, Float, Integer, long and short

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

T/F
Wrapper classes are final classes so you can’t extend them. Primitive types do not have methods, so the methods related to a primitive type are located in the corresponding type-wrapper class

A

T

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

takes primitives (int, double, Boolean, float, etc) and turn them into reference (Double, Integer, etc) types (generic classes/containers require reference classes).

converts a primitive type to an object of the corresponding type-wrapper class (reference type). Performed automatically

A

Boxing

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

Our of reference into primitive type

A

Unboxing

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

What are proper generic classes

A

ArrayList, LinkedList, Iterator, Map, Set

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

___________ is the same as an array, but it is dynamic/mutable (resizable).

A

ArrayList

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

T/F the List interface is implemented by ArrayList and LinkedList

A

True

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

List [name] = new ArrayList<>();

A

T

17
Q

a collection that associates keys to values and cannot contain duplicate keys. _____ does NOT derive from Collection.

A

Map

18
Q

a collection that does not contain duplicates

A

Set

19
Q

an ordered collection that can contain duplicate elements.

A

List

20
Q

Methods such as sort, reverse, addAll, shuffle etc are from

A

Static class collections (contains bulk operations)

21
Q

What does method Add() do from class List

A

adds elements to the end of the List

22
Q

From List

appends all elements of one list to another. Example: list1.addAll(list2); sets list2 to null.

A

AddAll

23
Q

From List

Prints list contents

A

printList

24
Q

Iterator uses

A

When you want to change the contents (for loop goes through contents)

25
Q

At runtime, behavior occurs based on what is received. Common example is with Inheritance

A

Polymorphic

26
Q
assumption) example “l = []” knows it is a list, whatever is in the list determines the type. In generic classes and methods
Or: Map m = new HashMap();
A

Type inferencing