Using Objects and Methods 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.
Dot operator
Random integer in a range
double
Primitive vs reference types
substring(a, b)
Autoboxing and unboxing
boolean
Math.random
Passing a reference to a method
void method
Instantiation
null
Short answer 1. Define or explain: Integer division
3 ptsShort answer 2. Define or explain: equals vs == for Strings
3 ptsShort answer 3. Define or explain: indexOf
3 ptsShort answer 4. Define or explain: Class vs object
3 ptsFree response
6 ptsThis course has no free-response prompt tagged to this unit, so one from elsewhere in the course is used. It is still worth writing — the skill transfers.
A 2D int array grid represents daily rainfall readings; each row is one week and each column is one day. Write two static methods. (a) public static int rowTotal(int[][] grid, int row) — returns the sum of the values in the given row. (b) public static int driestWeek(int[][] grid) — returns the index of the row with the smallest total. If two rows tie, return the lower index. Assume grid has at least one row and that all rows have the same length. Method (b) should call method (a).