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.
Return type
String concatenation
boolean
Class vs object
Math.random
nextInt then nextLine
null
Instantiation
Method overloading
int
Compound assignment
length()
Short answer 1. Define or explain: System.out.print vs println
3 ptsShort answer 2. Define or explain: Random integer in a range
3 ptsShort answer 3. Define or explain: Passing a primitive to a method
3 ptsShort answer 4. Define or explain: compareTo
3 ptsFree response
4 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.
Write a method `findLongestStreak(int[] arr)` that takes an array of integers and returns the length of the longest consecutive sequence of identical numbers. For example, if arr is {1, 2, 2, 2, 3, 3, 1}, the method should return 3.