Abstraction and Program Design FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

A cafeteria wants a RecycleBin class. Each bin has a color and a current weight in kilograms. Staff can add a weight, empty the bin so its weight becomes 0, and report whether the bin is over 20 kilograms. (a) Name the class and list two attributes. (b) List three behaviors as method names with a brief description of each. (c) Identify one attribute as instance data and explain why it is not shared by every bin. Use everyday language or a simple diagram. Full Java source is not required.

Question 2 of 5

A ParadeFloat class currently uses one method prepare() to do all of the work in the table, in order. Rewrite the design using method decomposition.

Order Task
1 Check the lights
2 Load the music
3 Test the motor
4 Log a ready note

(a) Name smaller methods for these tasks and say which one prepare should call first. (b) Explain one benefit of this decomposition if the motor test later changes. (c) Identify whether this redesign is mainly data abstraction or procedural abstraction and justify your choice.

Question 3 of 5

Design a BikeShareDock class. Each dock tracks its own bikeCount. Every dock in the city must use the same cityFee. (a) Classify bikeCount and cityFee as instance or class attributes and justify each choice. (b) Name two behaviors the dock should have. (c) Explain why copying cityFee onto every dock as a separate instance variable is a weaker design if the city wants one shared fee.

Question 4 of 5

A PasswordMask object stores a secret. Callers use matches(String attempt), which returns whether the attempt is correct. Callers cannot read the stored secret. (a) Explain how this design uses data abstraction. (b) Explain how matches uses procedural abstraction. (c) Describe one internal change that is allowed if matches still returns the same true/false results for the same attempts.

Question 5 of 5

A GreenhouseVent class has openForMorning() that always opens the vent for 15 minutes. Staff now need 10, 15, or 25 minutes from the same kind of action. (a) Rewrite the behavior as a parameterized method and explain how the parameter generalizes the procedure. (b) Give one example of an internal change that is allowed if the new signature and the specified timing behavior stay the same. (c) Explain why making three copy-paste methods open10, open15, and open25 is a weaker design.