Ask Question
22 May, 00:25

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.

+4
Answers (1)
  1. 22 May, 03:45
    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?
Get 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 & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers