Data Collections unit test
A test on this unit alone, marked as a percentage and a letter grade — for the test your class is actually sitting, rather than for May. Answer everything, then submit once: seeing the answer to question 3 before attempting question 4 makes the final percentage meaningless.
2D array element assignment
2D array
Standard algorithm: sum of a 2D array
Comparing objects in a collection
Array vs ArrayList
Choosing an array or an ArrayList
set(index, obj)
ArrayList of objects
Array
Initializing an ArrayList with values
Array of Strings and .length confusion
Total iterations over a 2D array
Short answer 1. Define or explain: Nested collection traversal cost
3 ptsShort answer 2. Define or explain: Enhanced for loop with objects
3 ptsShort answer 3. Define or explain: Standard algorithm: count elements meeting a condition
3 ptsShort answer 4. Define or explain: Row and column length
3 ptsFree response
9 pts2D ARRAY (Question 4, 9 points). A theater's seating chart is represented by the Theater class, which has a private instance variable boolean[][] seats. The entry seats[r][c] is true if the seat in row r, column c is occupied and false if it is empty. The array is rectangular with at least one row and one column. You will write two Theater methods. public int emptyCount() — returns the total number of empty seats in the theater. public boolean seatGroup(int row, int size) — searches the given row from left to right for the first run of size consecutive empty seats. If such a run is found, the method marks all size of those seats as occupied and returns true. If no such run exists, the method makes no change and returns false. You may assume 0 ≤ row < seats.length and size > 0. (For example, if row 2 is [true, false, false, false, true, false, false] and size is 3, the method marks columns 1, 2 and 3 as occupied and returns true. If size were 4, the method would change nothing and return false.)
A. Write method emptyCount.
B. Write method seatGroup.