Question: Write a Java class called Employee (Parts of the code is given below), which has three private fields firstName (String), lastName (String) and yearsEmployed (double).
Write a Java class called Employee (Parts of the code is given below), which has three private
fields firstName (String), lastName (String) and yearsEmployed (double). Implement
accessor/mutator methods for the private fields and toString() method, that returns a String
representation, which contains employee name and years she was employed.
public class Employee {
private String firstName;
...
}
Write a client program called EmployeeClient that creates an instance of Employee class, sets
values for the fields (name: John Doe, yearsEmployed: 4.5), and prints out the information about
an object.
Please note that you need to create 2 source files one for the class implementation
(Employee.java) and one for the client code (EmployeeClient.java).
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
