25.8k views
4 votes
Write the definition of a class employee base on the modular specification: . A data member for Id of type int (private). A data member for EmpName of type string (private). A data member for Salary of type double (private). A method to display the fields Id, EmpName, and Salary.

1 Answer

1 vote

Answer:

public class Employee {

private int id;

private String empName;

private double salary;

public void displayEmployee(){

System.out.print("Employee ID: " + id + "\\Employee name: " + empName + "\\Salary: " + salary);

}

}

Step-by-step explanation:

- Declare the class variables

- Write a method called displayEmployee to display the fields

User Muthu Palanisamy
by
5.1k points