January 2014
Intermediate to advanced
736 pages
70h 43m
English
To enable class BasePlusCommissionEmployee to directly access superclass instance variables firstName, lastName, socialSecurityNumber, grossSales and commissionRate, we can declare those members as protected in the superclass. As we discussed in Section G.3, a superclass’s protected members are accessible by all subclasses of that superclass. In the new CommissionEmployee class, we modified only lines 6–10 of Fig. G.4 to declare the instance variables with the protected access modifier as follows:
protected String firstName;protected String lastName;protected String socialSecurityNumber;protected double ...
Read now
Unlock full access