Purchase Solution

java: toString Methods

Not what you're looking for?

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

Purchase this Solution

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.

Solution Preview

Employee
// 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)
...

Purchase this Solution


Free BrainMass Quizzes
C# variables and classes

This quiz contains questions about C# classes and variables.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Basic Networking Questions

This quiz consists of some basic networking questions.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.