Chapter 9 - Multiple Choice Flashcards

1
Q
  1. What is/are the valid way(s) to declare a two-dimensional integer array named a? (Check all that apply.)

❑ int [ ][ ] a;

❑ int a [ ][ ];

❑ array [ ] int a;

❑ int array [ ] a;

A

int[ ][ ] a; and int a[ ][ ];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
  1. A two-dimensional array is an array of arrays.

❑ true

❑ false

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
  1. In a two-dimensional array, every row must have the same number of columns.

❑ true

❑ false

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q
  1. What is the default value of the elements of a two-dimensional array of booleans after declaration and instantiation of the array?

❑ true

❑ false

❑ undefined

A

false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
  1. How do you access the element of array a located at row 2 and column 4?

❑ a{2}{4}

❑ a( 2,4 )

❑ a[2][4]

❑ a[4][2]

A

a[2][4]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q
  1. How do you retrieve the number of rows in a two-dimensional array a?

❑ a.rows

❑ a.length

❑ a.rows( )

❑ a.size

A

a.length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
  1. How do you retrieve the number of columns in row 2 in a two-dimensional array a?

❑ a.length

❑ a[2].length

❑ a.size

❑ a[2].size

A

a[2].length

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
  1. All the elements of a two-dimensional array must be of the same type.

❑ true

❑ false

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
  1. An ArrayList can be returned by a method.

❑ true

❑ false

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
  1. It is possible to declare and instantiate an ArrayList of a user-defined class type.

❑ true

❑ false

A

true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
  1. As we add objects to an ArrayList, how can we be sure it has enough capacity?

❑ Use the setCapacity method.

❑ Use the trimToSize method.

❑ We don’t need to do anything; capacity expands automatically as needed.

A

We don’t need to do anything; capacity expands automatically as needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
  1. Where does the add method of the ArrayList class add an object?

❑ at the beginning of the list

❑ at the end of the list

A

at the end of the list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
  1. To what package does the class ArrayList belong?

❑ java.io

❑ java.util

❑ java.array

❑ java.list

A

java.util

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