While reverse engineering a billing system, you find that the class below is the only code that creates or modifies Invoice objects; assume nothing creates them by other means such as reflection or deserialization. Customer has no field referring to Invoice.
public class Invoice { private final Customer customer; private LineItem[] items; public Invoice(Customer customer) { if (customer == null) { throw new IllegalArgumentException("customer required"); } this.customer = customer; this.items = new LineItem[0]; } }
What multiplicity should the recovered class diagram show at the Customer end of the association between Invoice and Customer?
No multiplicity, because Customer is only a dependency of Invoice.
0..10..10..1, because any single reference field in Java can hold null.
1..∗1..*1..∗, because one customer can be billed on many invoices.
Exactly 111, because the constructor rejects null and the final field is never reassigned.
Unlock full course notes by signing up
True statements about reverse engineering
A team is reverse engineering an undocumented scheduling module to produce a class diagram. Which of the following statements about this work are true? Select all that apply.
Counting recovered relationships in a library system
The following Java source is the complete code of a small library system. String and LocalDate are library types.
Recover a class diagram using these rules: a field whose type is a project class gives an association; two fields in different classes that refer to each other form one bidirectional association; a project type used only as a method parameter gives a dependency. The fan-in of a class is the number of other project classes whose source names it. Give each answer as a whole number:
the number of generalizations,
Recovering upload termination behavior
You are reverse engineering an undocumented upload routine to describe its externally visible behavior. The Python implementation below returns a status and the number of send attempts. Each reply corresponds to one attempt. Every supplied list contains at least three replies, and slicing with replies[:3] selects only its first three entries.
Complete the recovered behavior table. Enter each status exactly as returned by the code and each attempt count as an exact integer. Each row is a separate run starting with sends equal to zero.
Recovering nested notification behavior
You are reverse engineering an event dispatcher whose subscriber list can change during a notification. The complete Python script is shown below. There are no other subscribers, exceptions, threads, or calls.
Each publish call invokes its subscribers in list order. The expression list(subscribers) creates a separate copy when that invocation enters its loop. Later additions to subscribers do not alter an existing copy. Calls execute synchronously: a caller waits for each called function to return.
Determine three exact integer counts: the total number of callback invocations across capture, audit, and metrics; the number of audit invocations; and the maximum number of simultaneously active publish invocations. A publish invocation remains active from entry until return, including while it waits for a nested call.