Class Employee
Class Employee (Fig. 8.8) has instance variables firstName, lastName, birthDate and hireDate. Members firstName and lastName are references to String objects. Members birthDate and hireDate are references to Date objects. This demonstrates that a class can have as instance variables references to objects of other classes. The Employee constructor (lines 12–19) takes four parameters representing the first name, last name, birth date and hire date. The objects referenced by the parameters are assigned to the Employee object’s instance variables. When class Employee’s toString method is called, it returns a String containing the employee’s name and the String representations of the two Date objects. Each of these Strings is obtained ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access