Question 5-1

When you pass a Customer object (of the class you defined in Lab 5) to the println class method in the IO class, it will print a nonsensical message. How could you modify the Customer class so that it displays the customer's name instead?

Solution

It can accomplish this by overriding the toString() instance method inherited from the Object class. In this case, we would want the toString() method to return the name of the customer.

Back to Review for Quiz 5