Consider the Java code below, where Customer and Printer are classes defined elsewhere in the same program. When each relationship in this code is drawn as a line on the class diagram, which statements are true? Select all that apply.
public interface Payable { double amountDue(); } public class Invoice implements Payable { private Customer customer; private double total; public double amountDue() { return total; } public void print(Printer p) { p.send(this); } }
The attribute total appears in the box as + total: double because amountDue returns it publicly.
Invoice connects to Printer by a dashed line ending in an open arrowhead at Printer.
Invoice connects to Customer by a hollow triangle because each invoice is built around a customer.
Invoice connects to Customer by a solid association line because customer is a field.
Invoice connects to Payable by a dashed line ending in a hollow triangle at Payable.
Unlock full course notes by signing up
Counting members and visibility in class boxes
The class diagram for a vehicle-tracking program is written out below, one class per row. Members in the same compartment are separated by semicolons. Truck is a subclass of Vehicle.
Count only the members drawn in each box. Inherited members are not repeated in a subclass box, and a constructor counts as an operation. Complete the table with whole numbers.
Java keywords behind abstract, static and read-only notation
When you turn a UML class diagram into Java, several pieces of notation each map to a single Java keyword. A class whose name is set in italics cannot be instantiated directly, so it becomes a class declared with the keyword ________. An attribute or operation shown underlined belongs to the class itself rather than to each object, so it becomes a member declared with the keyword ________. An attribute followed by the property {readOnly}, whose value cannot change once it is set, becomes a field declared with the keyword ________.
Minimum objects from a many-to-many multiplicity
In a UML class diagram for a high-school timetable, Section and Student are joined by an association. The multiplicity beside Student is 20..35 and the multiplicity beside Section is 1..6. The school plans to run 48 sections. What is the minimum number of Student objects that lets every section meet the lower bound of its range? Answer as a whole number.
Object counts allowed by a one-to-many multiplicity
A company's staff records are modelled by the UML class diagram below. The association between Department and Employee has multiplicity 1 at the Department end and 3..8 at the Employee end.
Using only the constraints in the diagram, find:
the minimum and the maximum total number of employees when the company has exactly 5 departments;