Unit 1: Using Objects and Methods
CS A · Unit 1 · Paper 2

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.

Each paper is built from this unit’s 43 terms and is the same for everyone, so a teacher can assign “Unit 1, Paper 2” and every student sits the identical test. Multiple choice is marked objectively; the written sections you mark yourself against the model answer and rubric.
Suggested time 31 min 28 points0/17 attempted
1

Return type

2

String concatenation

3

boolean

4

Class vs object

5

Math.random

6

nextInt then nextLine

7

null

8

Instantiation

9

Method overloading

10

int

11

Compound assignment

12

length()

Short answer 1. Define or explain: System.out.print vs println

3 pts

Short answer 2. Define or explain: Random integer in a range

3 pts

Short answer 3. Define or explain: Passing a primitive to a method

3 pts

Short answer 4. Define or explain: compareTo

3 pts

Free response

4 pts

This 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.