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.

Respuesta :

Answer:

public class Employee {

   private int id;

   private String empName;

   private double salary;

   

   public void displayEmployee(){

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

   }

}

Explanation:

- Declare the class variables

- Write a method called displayEmployee to display the fields

ACCESS MORE
EDU ACCESS
Universidad de Mexico