Ask Question
25 November, 20:27

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.

+4
Answers (1)
  1. 25 November, 23:21
    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?
Find 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 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