Ask Question
22 May, 13:07

Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of type String. Supply a method toString that prints the manager's name, department, and salary. Make a class Executive inherit from Manager. Supply appropriate toString & equals methods for all classes. Supply a test program that tests these classes and methods.

+2
Answers (1)
  1. 22 May, 13:47
    0
    see explaination

    Explanation:

    class Employee

    {

    String name;

    double salary;

    void tostring ()

    {

    System. out. println ("Employee:/nName: "+name+"/nSalary: "+salary+"/n");

    }

    Employee (String n, double s)

    {

    name=n;

    salary=s;

    }

    }

    class Manager extends Employee

    {

    String department;

    void tostring ()

    {

    System. out. println ("Manager:/nName: "+name+"/nDepartment: "+department+"/nSalary: "+salary+"/n");

    }

    Manager (String n, double s, String d)

    {

    super (n, s);

    department=d;

    }

    }

    class Executive extends Manager

    {

    void tostring ()

    {

    System. out. println ("Executive:/nName: "+name+"/nDepartment: "+department+"/nSalary: "+salary+"/n");

    }

    Executive (String n, double s, String d)

    {

    super (n, s, d);

    }

    }

    public class test

    {

    public static void main (String args[])

    {

    Employee e = new Employee ("Neo",12000);

    e. tostring ();

    Manager m = new Manager ("Cramster",100000,"Homework");

    m. tostring ();

    Executive ex = new Executive ("Chuks",1000000,"Homework");

    ex. tostring ();

    }

    }
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Make a class Employee with a name and salary. Make a class Manager inherit from Employee. Add an instance variable, named department, of ...” 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