Question
Following is the EmployeeTester class, which creates object of the class Employee and calls the methods of that object. The EmployeeTester class is written to
Following is the EmployeeTester class, which creates object of the class Employee and calls the methods of that object. The EmployeeTester class is written to test another class: Employee. You are required to implement the class Employee by:
- declaring its instance variables: name, age, salary.
- implementing its constructor.
- implementing its methods:
getEmployeeName(),
getEmployeeAge(),
getEmployeeSalary(),
setEmployeeAge(int empAge),
setEmployeeSalary(double empSalary)
public class EmployeeTester {
public static void main(String args[]) {
// Construct an object
Employee employeeOne = new Employee("Ahmad Abdullah");
// Call methods for the object
employeeOne.setEmployeeAge(30);
employeeOne.setEmployeeSalary(5000);
// Print the Employee details
System.out.println("Name:"+ employeeOne.getEmployeeName());
System.out.println("Age:" + employeeOne.getEmployeeAge() );
System.out.println("Salary:" + employeeOne.getEmployeeSalary() );
}
}
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