Page 1328 - AP Computer Science A, 7th edition
P. 1328

23. (D) Implementation I calls super.computePay(), which is equiv alent t o t he computePay m et hod in t he Employee superclass. The method returns the quantity (salary – taxWithheld). T he BONUS is t hen c orrec t ly added t o t his expression, as required. Implementation III correctly uses the public ac c es s or m et hods getSalary and getTax t hat t he Consultant class has inherited. Note that the Consultant class does not have direct access to the private instance v ariables salary and taxWithheld. Im plem ent at ion II incorrectly returns the salary plus BONUS—there is no tax withheld. The expression super.computePay() returns a value equal to salary minus tax. But this is neither stored nor included in the return statement.


































































































   1326   1327   1328   1329   1330