Question: In Fig. 8.8, class Employees instance variables are never modified after theyre initialized. Any such instance variable should be declared final. Modify class Employee accordingly,

In Fig. 8.8, class Employee’s instance variables are never modified after they’re initialized. Any such instance variable should be declared final. Modify class Employee accordingly, then compile and run the program again to demonstrate that it produces the same results.

Fig. 8.8

I // Fig. 8.8: Employee.java 2 // Employee class with references to other objects. 3 4 5 6 7 8 9 10 11 12 13

I // Fig. 8.8: Employee.java 2 // Employee class with references to other objects. 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 public class Employee { } private String firstName; private String lastName; private Date birthDate; private Date hireDate; // constructor to initialize name, birth date and hire date public Employee (String firstName, String lastName, Date birthDate, Date hireDate) { this.firstName = firstName; this.lastName = lastName; this.birthDate = birthDate; this.hireDate= hireDate; } // convert Employee to String format public String toString() { return String.format ("%s , %s Hired: %s Birthday: %s", lastName, firstName, hireDate, birthDate); }

Step by Step Solution

3.35 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Based on the code provided from the image and the instructions to declare an instance variable as final you need to initialize it once and only once I... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java How To Program Late Objects Questions!