Explore BrainMass

java: toString Methods

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 methods for all classes.
Supply a test program that tests these classes and methods.

Solution Preview

// Make a class Employee with a name and salary.
public class Employee {
public int salary;
public String name;

public String toString() {
return (this.name + " " + this.salary);

Employee Information
// Class to test the Employee, Executive, and Manger Class.
public class EmployeeInfo {
public static void main(String[] args)

Solution Summary

The solution contains all the 3 base classes and the other main class that utilizes the Manager, employee and executive classes. The code is properly commented to make it easier to understand.