Verityprep
Question Bank · Unit 1

AP® Computer Science A Using Objects and Methods FRQ

Work through AP Computer Science A free-response questions on Using Objects and Methods, then check each answer against a worked solution.

Free · no sign-up Open questions need no account. Sign up or log in to open the rest.

Questions 81–90 of 95
  1. 81
  2. 82
  3. 83
  4. 84
  5. 85
  6. 86
  7. 87
  8. 88
  9. 89
  10. 90

Question 81

Free response Using Objects
This question involves simulation of the play and scoring of a single-player video game. In the game, a player attempts to complete three levels. A level in the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 82

Free response Using Objects
This question involves the AppointmentBook class, which provides methods for students to schedule appointments with their teacher. Appointments can be scheduled…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 83

Free response Using Objects
Consider the following incomplete StringUtil class declaration. You will write implementations for the two methods listed in this class. Information about the…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 84

Free response Using Objects
This question involves the use of check digits, which can be used to help detect if an error has occurred when a number is entered or transmitted…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 85

Free response Using Objects
This question involves the `MessageBuilder` class, which is used to generate a message based on a starting word. The `MessageBuilder` class contains a helper…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 86

Free response Using Objects
The StringRotation class contains methods used to determine if a string is a rotation of another string. The declaration of the StringRotation class is shown…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 87

Free response Using Objects
A game application needs to process words. You will write two methods for the WordScrambler class, which has a single private instance variable: private String…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 88

Free response Using Objects
The Greenfield Public Library is undergoing a digital transformation. Every book in the library has a checkout record that includes the number of days it has…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 89

Free response Using Objects

The Riverside Bridge Authority operates an automated toll collection system. Vehicles crossing the bridge are charged based on the number of axles and the time of day. A standard 2-axle vehicle pays a base toll of $2.50. For each axle beyond two, an additional $1.25 is added to the base. During peak hours — defined as hours 7 through 9 and hours 16 through 18, inclusive, using a 24-hour clock — the total toll is multiplied by 1.5. During all other hours, no multiplier is applied.

PART A

Write the method public double calculateToll(int axles, int hour) that returns the toll as described above.

For example, calculateToll(2, 8) returns 3.75 (base 2.50 \(\times\) peak 1.5). calculateToll(5, 12) returns 6.25 (\(2.50 + 3 \times 1.25 = 6.25\), off-peak). calculateToll(3, 17) returns 5.625 (\((2.50 + 1.25) \times 1.5\)).

public double calculateToll(int axles, int hour) {

PART B

Write the method public int peakVehicleCount(ArrayList<Integer> hours) that counts how many entries fall within peak hours (7–9 or 16–18 inclusive).

For example, if hours is [6, 8, 12, 17, 18, 22, 7], the method returns 4 (entries 8, 17, 18, 7 are peak).

public int peakVehicleCount(ArrayList<Integer> hours) {
The answer and the full solution open in a window.

Question 90

Free response Using Objects
This problem involves the design of two classes that work together to analyze the letters in a word. The following LetterFrequency class is provided. public…

Sign up now. It's free!

See the full question with its answer and worked solution.

Question 81 of 95
Page 9 of 10