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

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 1” 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 33 min 30 points0/17 attempted
1

Primitive vs reference types

2

String immutability

3

String

4

Return type

5

Math.random

6

Method overloading

7

double

8

compareTo

9

Wrapper classes

10

Passing a primitive to a method

11

indexOf

12

Increment and decrement

Short answer 1. Define or explain: Casting

3 pts

Short answer 2. Define or explain: Passing a reference to a method

3 pts

Short answer 3. Define or explain: Static method call

3 pts

Short answer 4. Define or explain: Dot operator

3 pts

Free response

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

Design a class Coupon that represents a store coupon. A Coupon is constructed with a description (String) and a discount percent (int from 0 to 100). Values below 0 are stored as 0 and values above 100 are stored as 100. The class must provide: public Coupon(String desc, int percent) public int getPercent() public double priceAfter(double price) — the price after applying the discount public boolean betterThan(Coupon other) — true if this coupon’s percent is strictly greater public String toString() — for example "20% off winter boots" Write the complete class, including instance variables.