Answer:
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();
}
}