Review for Quiz 5
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?
Question 5-2
What does a .class file contain?
Solutions
Solution 5-1
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.
Solution 5-2
A .java file contains Java source code. When compiled,
the compiler produces a .class file containing
the corresponding machine code for the
Java Virtual Machine (JVM).