Ask Question
3 January, 08:21

Create a subclass of Person called Lecturer that has 2 variables of its own: employeeNumber and salary. As in the above scenario, these variables should be declared private with the appropriate getter and setter methods to access them.

+5
Answers (1)
  1. 3 January, 12:13
    0
    Following are the class is given below

    public class Lecturer extends Person

    {

    private String employeeNumber; / / private variable

    private double salary; / / private variable

    public String getempnumber () / / getter method for employeeNumber

    {

    return employeeNumber;

    }

    public void setempnumber (String employeeNumber) / / setter method for employeeNumber variable

    {

    this. employeeNumber = employeeNumber;

    }

    public double getempsalary () / /getter method for salary variable

    {

    {

    return salary;

    }

    public void setempsalary (double salary) / /setter method for salary variable

    {

    this. salary = salary;

    }

    }

    Explanation:

    In this program we create a subclass Lecturer which inherit person class we declared a two private member in this class one is employeeNumber which is String type because string can hold integer as well as characters and second is salary which is double type then after that we create a setter method and getter method for both the variable.

    for variable "employeeNumber" we create a public void setempnumber (String employeeNumber) for setter method and public int getempnumber () for getter method similarly for variable "salary" we create public void setempsalary (double salary) setter method and public double getempsalary () for getter method.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Create a subclass of Person called Lecturer that has 2 variables of its own: employeeNumber and salary. As in the above scenario, these ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers