431,467 views
25 votes
25 votes
Create a class named Employee. The class must contain member variables for the employee name and salary. It should contain getter methods for returning the name and salary. It should also contain setter methods for storing the name and salary. The class must include a constructor method for setting both the name and the salary. In addition, it should contain a toString() method.2- Create the client code to test the class Employee.

User Aysabzevar
by
3.1k points

1 Answer

18 votes
18 votes

Answer:

Step-by-step explanation:

The following code was written in Java. The code contains the Employee class which contains the two variables (name, salary), the constructor, getter and setter methods for both variables, and an overwritten toString method. It also contains a tester class with the main method inside and creates a Employee object and initializes it. Then it calls the toString method. The output can be seen in the attached image below. Due to technical difficulties I have added the code as a txt file below.

Create a class named Employee. The class must contain member variables for the employee-example-1
User Elysire
by
2.7k points