A team describes four features of a drawing application. Match each object-oriented principle to the description that most directly illustrates it. Each description has one intended match.
Circle is declared as a specialized Shape and receives its accessible common behavior.
A shape keeps its coordinates private and checks proposed coordinate changes through its methods.
A drawing tool exposes a small set of relevant operations while hiding rendering details.
The same draw request invokes different implementations for circle and rectangle objects.
Inheritance
Abstraction
Encapsulation
Polymorphism
Unlock full course notes by signing up
Follow one robot's charge
Two separate Robot objects, rover and scout, store their own battery charge percentages. Initially, rover has 54% charge and scout has 73% charge. The methods subtract or add the stated number of percentage points to the target robot's charge.
The following calls occur in order, and all succeed:
rover.consume(17)
Check requests before changing state
Two separate SnackDispenser objects, A and B, each hold at most 20 packets. Initially, A holds 8 packets and B holds 13 packets.
For each positive integer request, vend(k) removes exactly kkk packets if enough are available. The method load(k) adds exactly kkk packets if the resulting stock does not exceed 20. Otherwise, the request is rejected and the target object's stock stays unchanged. Neither method changes the other object.
Complete the table after each call, processing the rows from top to bottom. Enter yes or no for acceptance and exact integers for both stock counts.
Separate names from objects
In Python, Counter(n) creates a new object with its own stored count initially equal to nnn. Calling increment(k) adds kkk to that object's count. Assigning an existing object to another variable gives that variable a reference to the same object.
The following statements run in order:
Which statements about the final counts and object identities are true? Select all that apply.
Audit charges selected by runtime class
A parcel application uses the following class rules. All charges are in dollars, and no taxes or other fees apply.
Parcel.fee() returns 4.00plus4.00 plus 4.00plus1.50 per kilogram of mass.
InsuredParcel specializes Parcel and overrides fee(). Its method calculates the charge using the Parcel formula, then adds 2% of the declared value.