Ask Question

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. 14 January, 17:59
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers