A library prototype fills five storage slots with references, then replaces two entries. After the Java code finishes, how many distinct ordinary Object instances are referenced by the entries of slots? Exclude the array object itself. Give an exact whole-number count, with no decimal places.
Object shared = new Object(); Object[] slots = new Object[5]; for (int i = 0; i < slots.length; i++) { slots[i] = shared; } slots[1] = new Object(); slots[4] = new Object();
Unlock full course notes by signing up
A common method for logging
A Java logging helper receives a non-null Object reference named parcel and needs a String representation of its object. Complete the public method name, without parentheses: ________.
Four requirements for a reliable equality method
A developer is reviewing an equality method for shipment labels. The equals contract specifies rules that a correct Java equality method follows. Match each named property to its requirement. Throughout the requirements, x, y, and z are non-null references.
Check type, identity, and null separately
A sign-control program executes the following Java declarations. Evaluate each proposed expression independently, so a failure in one does not prevent consideration of another. Select every true statement.
Repairing a catalog hash-code audit
A catalog program has seven distinct, non-null CatalogEntry objects. Its equality method satisfies the Object.equals contract and considers two entries equal exactly when their product IDs match. The table shows proposed hashCode() results for a test run.
You are correcting the proposed results before running the test. A changed entry means one row receives a different hash-code integer. Any Java int value may be used. The corrected results must satisfy the relationship between equals and hashCode; the equality results and product IDs remain fixed. Each corrected result will remain stable throughout the run.
Determine these three quantities, each as an exact integer count: