Abstraction and Program Design FRQ Practice

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

Question 1 of 5

A ferry office wants a FerryTicket class. Each ticket stores a passenger name and a seatLetter. Staff can mark the ticket boarded or print a boarding line. (a) Identify the class, two attributes, and two behaviors. (b) Draw or describe a simple diagram that shows which pieces are attributes and which are behaviors. (c) Explain why passenger name should be instance data rather than one class variable shared by every ticket.

Question 2 of 5

A cafeteria designs a LunchTray class. Each tray has its own remainingCalories. All trays share one maxCalories limit set by the school. (a) Classify remainingCalories and maxCalories as instance or class attributes and justify. (b) Name two behaviors, including one that uses remainingCalories. (c) Explain one problem if maxCalories were stored only as a separate instance copy on every tray when the school wants a single shared limit.

Question 3 of 5

A WeatherBuoy class has one method service() that currently performs every row in the table in order. Decompose the design.

Order Task
1 Wipe the sensor
2 Calibrate the compass
3 Send a status ping
4 Close the hatch

(a) Name helper methods and state the order service should call them. (b) Explain how this decomposition uses procedural abstraction. (c) Explain why the helpers should not be stored as integer attributes.

Question 4 of 5

A BadgePrinter stores ink data privately. Callers use public void printLine(String text), specified to print one line. They never read the ink data. (a) Explain the data abstraction in this design. (b) Explain the procedural abstraction in printLine. (c) Describe one allowed internal change and one change that would be illegal because it alters the signature or specified behavior.

Question 5 of 5

A TrailKiosk method announce() always speaks a 20-second safety message. Rangers now need 15, 20, or 30 seconds using the same kind of action. (a) Redesign announce with a parameter and explain how the parameter generalizes the procedure. (b) Explain what may change inside the method if the new signature and specified timing behavior remain. (c) Compare this parameterized design with writing announce15, announce20, and announce30 as three separate copies.