Question
Instance Variables) In Fig. 8.8 , class Employees instance variables are never modified after theyre initialized. Any such instance variable should be declared final. Modify
Instance Variables) 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, then compile and run the program again to demonstrate that it produces the same results.
Here is the code that need to be modified.
public class Employee {
private String firstName; private String lastName; private Date birthDate; private Date hireDate;
public Employee(String firstName, String lastName, Date birthDate, Date hireDate) { this.firstName = firstName; this.lastName = lastName; this.birthDate = birthDate; this.hireDate = hireDate; } public String toString(){ return String.format("%s, %s, Hired: %s Birthday: %s", lastName, firstName, hireDate, birthDate); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started