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 1.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.
  • A call to fee() selects the implementation belonging to the object's actual runtime class, even when the reference variable is declared as Parcel.

Each row represents a different object. Every reference in the list is declared as Parcel.


Object

Actual runtime class

Mass (kg)

Declared value (dollars)

North

Parcel

4

Not applicable

East

InsuredParcel

2

300

West

InsuredParcel

6

500


The application calls fee() once on each object and adds the returned amounts. An auditor instead applies the Parcel formula to every row, ignoring the actual runtime classes.


Find the application's total charge and the amount by which the auditor underestimates that total. Give both answers in dollars, to two decimal places.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More The Object-Oriented Paradigm Questions: