Chapter 9 - Multiple Choice Flashcards
- 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;
int[ ][ ] a; and int a[ ][ ];
- A two-dimensional array is an array of arrays.
❑ true
❑ false
true
- In a two-dimensional array, every row must have the same number of columns.
❑ true
❑ false
false
- 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
false
- 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[2][4]
- How do you retrieve the number of rows in a two-dimensional array a?
❑ a.rows
❑ a.length
❑ a.rows( )
❑ a.size
a.length
- 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[2].length
- All the elements of a two-dimensional array must be of the same type.
❑ true
❑ false
true
- An ArrayList can be returned by a method.
❑ true
❑ false
true
- It is possible to declare and instantiate an ArrayList of a user-defined class type.
❑ true
❑ false
true
- 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.
We don’t need to do anything; capacity expands automatically as needed
- Where does the add method of the ArrayList class add an object?
❑ at the beginning of the list
❑ at the end of the list
at the end of the list
- To what package does the class ArrayList belong?
❑ java.io
❑ java.util
❑ java.array
❑ java.list
java.util